- Home /
Terrain and character navigation
I'm fairly new to Unity and am developing my first game. I have created a terrain and have a character that I can move around on it. I'm just wondering if I'm doing it correctly. I'm having some issues with walking up stairs that I created with box colliders. Can you take a look at my code and see if I'm doing anything wrong?
Also I'm a little confused on what objects need what components (colliders, mesh, etc.) Hopefully this question isn't too vague. Just looking for a little guidance before I move forward.
Thank you!
 public class Player : MonoBehaviour {
 
 
       private CharacterController controller;
       [SerializeField]
       private float Speed = 6f;
       private float gravity = 9.81f;
       public float RotateSpeed = 6f;
      
     
     
 
      
 
     void Start () {
         controller = GetComponent<CharacterController>();
 
     }
     void Update () {
         // CalculateMovement();
         
           CharacterController controller = GetComponent<CharacterController>();
          if (transform != null)
          {
              transform.Rotate(0, Input.GetAxis("Horizontal") * RotateSpeed, 0);
              var forward = transform.TransformDirection(Vector3.forward);
              float curSpeed = Speed * Input.GetAxis("Vertical");
              controller.SimpleMove(forward * curSpeed);
          }
          
          
     
     }
     }
 
 
 
You are showing the wrong script. From what i see the movement is done inside Simple$$anonymous$$ove from CharacterController. You should edit your question and add that script too.
Your answer
 
 
             Follow this Question
Related Questions
Model/mesh has huge collider even though there is no collider added and even if there was why so big 1 Answer
Terrain Mesh Collider working in Unity 2018 and not in Unity 2020 0 Answers
Generate heightmap from Terrain object with code 1 Answer
Entire Project Turned Black and White Checkered after loading project up. Textures missing too. 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                