[TUTORIAL] Unity3D - Realistic Fps Prefab 1.44,1.45 - Sistema de Veículos - EVP5
Página 1 de 1
[TUTORIAL] Unity3D - Realistic Fps Prefab 1.44,1.45 - Sistema de Veículos - EVP5
Hoje eu estarei postando(Na vdd ja postei kk) meu script(Atualizado) de sistema de veículos utilizando o RFPS (Realistic Fps Prefab) 1.44|1.45 junto com o EVP5(Edy's vehicle physics), o Script foi criado por um gringo chamado Redhawk, porem estava desatualizado então eu o atualizei, para a versão mais recente no caso.
OBS: tenho permissões dele para postar.
Tutorial:
OBS: tenho permissões dele para postar.
- 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 ProBrStalker
{
public class VehicleInteractRFPS : MonoBehaviour {
#region Variables - Edy's
VehicleStandardInput m_VehicleStandardInput;
VehicleCameraController m_VehicleCameraController;
VehicleController m_VehicleController;
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_VehicleStandardInput = this.GetComponentInParent<VehicleStandardInput>();
m_VehicleStandardInput.enabled = false;
m_VehicleController = this.GetComponentInParent<VehicleController> ();
m_Target = m_VehicleController.transform;
//Components on EVP Camera
m_VehicleCameraController = vehicleCamera.GetComponentInParent<VehicleCameraController> ();
if (m_VehicleCameraController == null)
Debug.Log ("Add a VehicleCameraController to the vehicle camera!", vehicleCamera);
m_VehicleCameraController.enabled = false;
m_VehicleController.throttleInput = 0.0f;
m_VehicleController.brakeInput = 1.0f;
//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_VehicleStandardInput.enabled = true;
m_VehicleCameraController.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_VehicleController.throttleInput = 0.0f;
m_VehicleController.brakeInput = 1.0f;
m_VehicleStandardInput.enabled = false;
m_VehicleCameraController.enabled = false;
}
//User EVP Functionality
void UpdateEVPCameraSettings()
{
m_VehicleCameraController.target = m_Target;
m_VehicleCameraController.ResetCamera();
}
}
}
Tutorial:
Tópicos semelhantes
» Realistic fps prefab tenho esses erros ao tentar colocar um script de entrar sair do carro
» Sistema De Marchas para Veiculos
» {Tutorial} helicóptero e veiculos
» [TUTORIAL] Unity3d (Loading)
» [TUTORIAL] Unity3d GuiText (Pause)
» Sistema De Marchas para Veiculos
» {Tutorial} helicóptero e veiculos
» [TUTORIAL] Unity3d (Loading)
» [TUTORIAL] Unity3d GuiText (Pause)
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos