0

I am trying to make a 3D capsule climb up along an object I tagged as "Wall". However, when I make contact with the wall, It can't seem to rise along the wall. How would this be fixed?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class WallClimb : MonoBehaviour
{
   public float riseSpeed;
   public Rigidbody rb;

private void start()
{
    riseSpeed = 5.0f;
}

private void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.CompareTag("Wall"))
    {
        Debug.Log("Position: " + transform.position);
        rb.velocity = transform.up * riseSpeed;
        
        Debug.Log("Wall Hit");
    }
}
}

1 Answers1

0

Maybe when you are pressing 'w' there are 2 forces acting on the wall 1 is upward and 1 in direction of the wall, and the force in direction of the wall won't let you go upwards, also make sure there is no friction on the wall.