|
Post by ammarofficial11 on Sept 19, 2019 3:34:18 GMT
Hi Guys,
I tried to change Camera State during close melee combat by create a new Camera State 'Combat'. So, I would give a trigger collider to each of my enemies with vTriggerChangeCameraState script in it. Whenever my player step in the collider, camera state change from 'Default' to ''Combat' and everything works well. When my player exit the trigger collider, Camera State change back to 'Default' state.
But my problem is, this method override override 'Aiming' Camera State when my player equipped shooter weapon and aiming inside the trigger collider. So, how can I run this triggercamera state only if player unequip?
|
|
|
Post by Invector on Sept 19, 2019 14:24:28 GMT
Are you using the Inventory? if yes you can use the vCheckItemIsEquipped to filter the items that will enable/disable the trigger object when equip/unequip
|
|
|
Post by ammarofficial11 on Sept 19, 2019 19:31:45 GMT
Yes, im using the inventory, but I cannot find where vCheckItemIsEquipped is?
|
|
|
Post by ammarofficial11 on Sept 19, 2019 22:55:10 GMT
Ive solved it.. I took isAiming bool from vShooterMeleeInput. Check for its value first before trigger camera state to 'Combat'. Here some changes Ive made on vtriggerChangeCameraState:
private vThirdPersonInput tpInput;
public GameObject player;
public vShooterMeleeInput canaiming;
public bool canaim = false;
void Start()
{
canaiming = player.GetComponent<vShooterMeleeInput>();
}
void Update()
{
canaim=player.GetComponent<vShooterMeleeInput>().isAiming;
if (canaim == true)
{
Debug.Log("can aim");
}
else
Debug.Log("cant aim");
}
void OnTriggerEnter(Collider other)
{
if (canaim == false) //if not aiming, change camera state to 'Combat' when enter collider
{
if (other.gameObject.CompareTag("Enemy"))
{
// Debug.Log("enter collider");
if (tpInput == null || tpInput.gameObject != player.gameObject)
tpInput = player.GetComponent<vThirdPersonInput>();
if (tpInput)
{
tpInput.smoothCameraState = smoothTransition;/// apply lerp transition between states
tpInput.customCameraState = cameraState; /// change the camera state to a new string
tpInput.customlookAtPoint = customCameraPoint;/// set new target for the camera
tpInput.changeCameraState = (!string.IsNullOrEmpty(cameraState));/// activate custom camera state on the controller
tpInput.keepDirection = keepDirection;/// set Input to keep Direction
}
}
}
}
void OnTriggerStay(Collider other)
{
if (canaim == true) //if player start aiming inside collider, reset camera state to 'Default'. 'Aiming' state will auto change
{
if (other.gameObject.CompareTag("Enemy"))
{
if (tpInput == null || tpInput.gameObject != player.gameObject)
tpInput = player.GetComponent<vThirdPersonInput>();
if (tpInput)
{
tpInput.ResetCameraState();
}
}
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.CompareTag("Enemy")) // if player leave collider, reset to default camera state
{
// Debug.Log("Out collider");
if (tpInput == null || tpInput.gameObject != player.gameObject)
tpInput = player.GetComponent<vThirdPersonInput>();
if (tpInput)
{
tpInput.ResetCameraState();
}
}
}
|
|