Im not sure if this is the right place but, I was following a youtube tutorial for building a ladder and the code only works when player’s rigibody is set to kinematic. However when it is on kinematic my player can’t move plus when I try exiting the box collider so the controller can climb it wont let me exit. Any help would be apreciated. Im trying to learn and thought the specific tutorial sereis would be a great place to start. Here is the code.
using UnityEngine;
public class Ladder : MonoBehaviour
{
public Transform playerController;
bool inside = false;
public float speed = 3f;
public FirstPersonController player;
public AudioSource sound;
void Start()
{
player = GetComponent<FirstPersonController>();
inside = false;
}
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Ladder")
{
Debug.Log("TouchingLadderTrue");
player.enabled = false;
inside = !inside;
}
}
void OnTriggerExit(Collider col)
{
if (col.gameObject.tag == "Ladder")
{
Debug.Log("TouchingLadderFalse");
player.enabled = true;
inside = !inside;
}
}
void Update()
{
if (inside == true && Input.GetKey("w"))
{
player.transform.position += Vector3.up /
speed * Time.deltaTime;
}
if (inside == true && Input.GetKey("s"))
{
player.transform.position += Vector3.down /
speed * Time.deltaTime;
}
if (inside == true && Input.GetKey("w"))
{
sound.enabled = true;
sound.loop = true;
}
else
{
sound.enabled = false;
sound.loop = false;
}
}
}