Hi sorry for any misspelled word english aint my first language…
If anyone could give me any info to help me learn the logic behind it i am totally lost since im pretty new to all of that.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class stairsVar : MonoBehaviour
{
private PlayerMovement playerController;
private HeadBobController headBob;
private void Awake()
{
playerController = GetComponent<PlayerMovement>();
headBob = GetComponent<HeadBobController>();
}
private void OnTriggerEnter(Collider collider)
{
Debug.Log(collider);
headBob.Able();
playerController.EnterStairs();
}
private void OnTriggerExit(Collider collider)
{
Debug.Log(collider);
headBob.Disable();
playerController.ExitStairs();
}
}
and here is the functions from HeadBob
public void Able()
{
_enable = true;
Debug.Log("ye");
}
public void Disable()
{
_enable = false;
Debug.Log("ye");
}
and here from PlayerMovement
public float walkSpeed = 4f;
public float currentSpeed;
public float crouchedSpeed = 2f;
public float runSpeed = 8f;
public float gravity = -28f;
[Header("onStairsStat")]
[SerializeField] float newGravity = -3000f;
[HideInInspector] float oldGravity = -28f;
[SerializeField] float newRunSpeed = 6f;
[HideInInspector] float oldRunSpeed = 8f;
[SerializeField] float newWalkSpeed = 3f;
[HideInInspector] float oldWalkSpeed = 4f;
[SerializeField] float newCrouchedSpeed = 1f;
[HideInInspector] float oldCrouchedSpeed = 2f;
public void ExitStairs()
{
gravity = oldGravity;
runSpeed = oldRunSpeed;
walkSpeed = oldWalkSpeed;
crouchedSpeed = oldCrouchedSpeed;
Debug.Log("ye");
}
public void EnterStairs()
{
gravity = newGravity;
runSpeed = newRunSpeed;
walkSpeed = newWalkSpeed;
crouchedSpeed = newCrouchedSpeed;
Debug.Log("ye");
}
Here is the actual error code
FPP (UnityEngine.CharacterController)
UnityEngine.Debug:Log (object)
StairsVar:OnTriggerExit (UnityEngine.Collider) (at Assets/Scripts/StairsVar.cs:22)