I'm not using a rigid body controller and I'm having troubles making a ladder for the character controller
using System.Collections.Generic;
using UnityEngine;
public class Ladder : MonoBehaviour
{
public CharacterController controller;
public float speed = 12f;
Vector3 velocity;
public float thrust = 20f;
public AudioSource sound;
bool inside = false;
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Debug.Log("TouchingLadderTrue");
inside = true;
}
}
void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player"))
{
inside = false;
}
}
void Update()
{
if (inside == true && Input.GetKeyDown(KeyCode.W))
{
velocity.y = Mathf.Sqrt(thrust * speed * Time.deltaTime);
}
if (inside == true && Input.GetKeyDown(KeyCode.S))
{
//
}
if (inside == true && Input.GetKeyDown(KeyCode.W))
{
sound.enabled = true;
sound.loop = true;
}
else
{
sound.enabled = false;
sound.loop = false;
}
}
}```