Erro no Script- "The script needs to derived from MonoBehavior"
2 participantes
Página 1 de 1
Erro no Script- "The script needs to derived from MonoBehavior"
- Código:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EVP;
///NOTES
/// Set this object tag to Usable, ensure Vehicle Camera is not tagged as MainCamera
///
namespace RedHawk
{
public class HelicopterInteractRFPS : MonoBehaviour {
#region Variables - Edy's
ControlPanel m_ControlPanel;
FollowTargetCamera m_FollowTargetCamera;
HeliRotorController m_HelicopterController;
Transform m_Target;
#endregion
[Tooltip("Ensure your Vehicle Camera is untagged. If it is tagged as MainCamera, RFPS will not work properly.")]
public GameObject vehicleCamera = null;
[Tooltip("Vehicle Child Game Object which represents the position the player will exit at. If omitted, one will be automatically created.")]
public GameObject exitPosition = null;
bool inVehicle=false;
#region Variables - RFPS
private FPSPlayer FPSPlayerComponent;
GameObject m_Body = null;
bool m_BodyVisible = false;
GameObject m_MainCamera = null;
GameObject m_WeaponCamera = null;
GameObject m_WeaponObj = null;
#endregion
void Awake(){
//Camera Checks and initial setup due to RFPS
Camera tmpCam = null;
if (vehicleCamera.GetComponentInChildren<Camera> (true) != null)
tmpCam = vehicleCamera.GetComponentInChildren<Camera> (true);
if (tmpCam == null)
Debug.Log ("The Vehicle Camera was not found. Please add one!", gameObject);
if (tmpCam.tag == "MainCamera") {
Debug.Log ("The Vehicle Camera is set to MainCamera. This needs to be changed for RFPS", vehicleCamera);
vehicleCamera.SetActive (false);
this.enabled = false;
}
vehicleCamera.GetComponentInChildren<Camera> (true).enabled = false;
vehicleCamera.GetComponentInChildren<AudioListener> (true).enabled = false;
if (this.tag != "Usable") {
Debug.Log ("The tag of this object should be set to Usable to work with RFPS", this);
this.enabled = false;
}
m_MainCamera = Camera.main.gameObject;
m_WeaponCamera = m_MainCamera.transform.GetComponentInParent<ReconfigurePrefab> ().WeaponCamera;
m_WeaponObj = m_MainCamera.transform.GetComponentInParent<ReconfigurePrefab> ().WeaponObj;
}
public virtual void Start(){
//Components on EVP Parent Vehicle
m_ControlPanel = this.GetComponentInParent<ControlPanel>();
m_ControlPanel.enabled = false;
m_HelicopterController = this.GetComponentInParent<HeliRotorController> ();
m_Target = m_HelicopterController.transform;
//Components on EVP Camera
m_FollowTargetCamera = vehicleCamera.GetComponentInParent<FollowTargetCamera> ();
if (m_FollowTargetCamera == null)
Debug.Log ("Add a VehicleCameraController to the vehicle camera!", vehicleCamera);
m_FollowTargetCamera.enabled = false;
//Exit Position
if(exitPosition == null){
exitPosition = new GameObject("ExitPosition");
exitPosition.transform.SetParent(m_Target);
exitPosition.transform.localPosition = new Vector3(-1f, 0f, 0f);
exitPosition.transform.localRotation = Quaternion.identity;
}
//RFPS
FPSPlayerComponent = m_MainCamera.GetComponent<CameraControl> ().playerObj.GetComponent<FPSPlayer> ();
if (FPSPlayerComponent.gameObject.GetComponent<FPSRigidBodyWalker> ().PlayerCharacterObj != null)
m_Body = FPSPlayerComponent.gameObject.GetComponent<FPSRigidBodyWalker> ().PlayerCharacterObj;
if (m_Body != null)
m_BodyVisible = FPSPlayerComponent.gameObject.GetComponent<FPSRigidBodyWalker> ().PlayerCharacterComponent;
}
void FixedUpdate()
{
if (inVehicle) {
if (Input.GetButtonDown ("Use"))
ExitVehicle ();
}
}
//RFPS Called Action for Usable Objects - see FPSPlayer
public virtual void ActivateObject()
{
//Debug.Log ("We've Been Activated");
EnterVehicle ();
inVehicle = true;
}
//Enter Vehicle
public virtual void EnterVehicle()
{
//Debug.Log ("We Entered Vehicle!");
//RFPS Player
FPSPlayerComponent.gameObject.SetActive(true);
FPSPlayerComponent.transform.SetParent (m_Target);
FPSPlayerComponent.transform.position = m_Target.position;
if (m_BodyVisible) { //If DisplayVisibleBody is true, then handle the body
m_Body.gameObject.SetActive (false);
m_Body.transform.SetParent (m_Target);
m_Body.transform.position = m_Target.position;
}
//RFPS Camera
m_MainCamera.GetComponent<AudioListener> ().enabled = false;
m_MainCamera.GetComponent<Camera>().enabled = false;
m_WeaponCamera.GetComponent<Camera> ().enabled = false;
m_WeaponObj.SetActive (false);
//Vehicle Camera
vehicleCamera.GetComponentInChildren<Camera> (true).enabled = true;
vehicleCamera.GetComponentInChildren<AudioListener> (true).enabled = true;
//EDYS
m_ControlPanel.enabled = true;
m_FollowTargetCamera.enabled = true;
// UpdateEVPCameraSettings ();
}
//Exit Vehicle
public virtual void ExitVehicle()
{
//Debug.Log ("We Exited Vehicle!");
inVehicle = false;
//RFPS Player
FPSPlayerComponent.transform.parent = null;
FPSPlayerComponent.transform.position = exitPosition.transform.position;
FPSPlayerComponent.transform.rotation = exitPosition.transform.rotation;
FPSPlayerComponent.gameObject.SetActive(true);
if (m_BodyVisible) { //If DisplayVisibleBody is true, then handle the body
m_Body.transform.parent = null;
m_Body.transform.position = exitPosition.transform.position;
m_Body.transform.rotation = exitPosition.transform.rotation;
m_Body.gameObject.SetActive (true);
}
//RFPS Camera
m_MainCamera.GetComponent<Camera>().enabled = true;
m_MainCamera.GetComponent<AudioListener> ().enabled = true;
m_WeaponObj.SetActive (true);
m_WeaponCamera.GetComponent<Camera> ().enabled = true;
//Vehicle Camera
vehicleCamera.GetComponentInChildren<Camera> (true).enabled = false;
vehicleCamera.GetComponentInChildren<AudioListener> (true).enabled = false;
//EDYS
m_ControlPanel.enabled = false;
m_FollowTargetCamera.enabled = false;
}
//User EVP Functionality
/* void UpdateEVPCameraSettings()
{
m_FollowTargetCamera.PositionFolowForce = m_Target;
m_FollowTargetCamera.camera;
} */
}
}
Re: Erro no Script- "The script needs to derived from MonoBehavior"
Ta usando versão pirata do asset EDY Vehicle Physics?
O que está tentando fazer com esse código da camera exatamente?
O que está tentando fazer com esse código da camera exatamente?
Re: Erro no Script- "The script needs to derived from MonoBehavior"
Não, isso é um sistema(Script) que eu modifiquei para que o jogador (fps e tps) possa entrar e sair do carro mas agora estou tentando modificar esse script para que o jogador posso entrar e sair do helicóptero...mas como não sou um bom programador ainda é muito dificíl para mim por isso vim procurar ajuda aqui.
Re: Erro no Script- "The script needs to derived from MonoBehavior"
Não, isso é um sistema(Script) que eu modifiquei para que o jogador (fps e tps) possa entrar e sair do carro mas agora estou tentando modificar esse script para que o jogador posso entrar e sair do helicóptero...mas como não sou um bom programador ainda é muito dificíl para mim por isso vim procurar ajuda aqui.MarcosSchultz escreveu:Ta usando versão pirata do asset EDY Vehicle Physics?
O que está tentando fazer com esse código da camera exatamente?
Tópicos semelhantes
» ERRO NO SCRIPT UM UNICO ERRO
» ERRO NO SCRIPT
» Não Acho o Erro no Script - é um script para o player se mover
» [SCRIPT]Erro de Script
» erro erro e mais erro script de craft
» ERRO NO SCRIPT
» Não Acho o Erro no Script - é um script para o player se mover
» [SCRIPT]Erro de Script
» erro erro e mais erro script de craft
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos