I’m creating a third-person ledge climbing game (Like uncharted) but I need to check if my ledge detector is touching a game object with the tag Ledge. At default, a boolean called is climbing is false, but when the ledge detector touches the tag, it should swithc the navigation controls for a new set of climbing controls. Though at the moment, I haven’t done the controls, I still need to get my ledge detector to check for tags.
//Movement
private Vector3 Velocity;
[SerializeField] private float Speed;
[SerializeField] private float JumpForce;
[SerializeField] private float Gravity;
public float SmoothTurnTime = 0.1f;
float TurnSmoothVelocity;
//Dynamic Climbing
private bool IsClimbing = false;
void Start()
{
}
void Update()
{
Movement();
Climbing();
}
private void Movement()
{
if (IsClimbing == false)
{
//Movement Script
float Horizontal = Input.GetAxisRaw("Horizontal");
float Vertical = Input.GetAxisRaw("Vertical");
Vector3 Direction = new Vector3(Horizontal, 0f, Vertical).normalized;
if (Direction.magnitude >= 0.1f)
{
float TargetAngle = Mathf.Atan2(Direction.x, Direction.z) * Mathf.Rad2Deg + Cam.eulerAngles.y;
float Angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, TargetAngle, ref TurnSmoothVelocity, SmoothTurnTime);
transform.rotation = Quaternion.Euler(0f, Angle, 0f);
Vector3 MoveDirection = Quaternion.Euler(0f, TargetAngle, 0f) * Vector3.forward;
Controller.Move(MoveDirection.normalized * Speed * Time.deltaTime);
}
//Sprinting Script
if (Input.GetKey(KeyCode.LeftShift))
{
Speed = 20f;
}
else
{
Speed = 10f;
}
//Gravity and Jumping Script
if (Controller.isGrounded)
{
Velocity.y = -1f;
if (Input.GetKeyDown(KeyCode.Space))
{
Velocity.y = JumpForce;
}
}
else
{
Velocity.y -= Gravity * -2f * Time.deltaTime;
}
Controller.Move(Velocity * Time.deltaTime);
}
}
private void Climbing()
{
if(IsClimbing == false)
{
------------------------------------
//!~-~!Need Help Here!~-~!\\
------------------------------------
}
}
If you have an alternative to using an object, please let me know.