Hey I have try a lot of movement methods but when I go on mountains there will be a glitch that do so I cant get up there, it’s just going through the mountain or it’s just flying away
You’ll need to provide more detail than that. Show the code you’re using to move the character. You haven’t said whether this is 2D or 3D, whether you’re using physics to move, etc.
oh sry
the last script I used was this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
public float speed = 6.0f;
public float jumpspeed = 8.0f;
public float gravity = 20.0f;
public float rotateSpeed = 3.0f;
private Vector3 moveDirection = Vector3.zero;
void Start ()
{
}
void Update ()
{
CharacterController controller = GetComponent();
if (controller.isGrounded)
{
moveDirection = new Vector3(0, 0, Input.GetAxis(“Vertical”));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton(“Jump”))
moveDirection.y = jumpspeed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
transform.Rotate(0, Input.GetAxis(“Horizontal”), 0);
}
}
with a player collider
and it’s 3d
I have also tried this:
using UnityEngine;
public class PlayerController : MonoBehaviour
{
void Update()
{
var x = Input.GetAxis(“Horizontal”) * Time.deltaTime * 150.0f;
var z = Input.GetAxis(“Vertical”) * Time.deltaTime * 3.0f;
transform.Rotate(0, x, 0);
transform.Translate(0, 0, z);
}
}
The Standard Assets contains a couple of character controllers, one for physics-based movement, and one without. I’d recommend installing that (Assets → Import Package → Characters) and use one of those controllers instead of trying to make your own controller from scratch. Then you can customize the controller to suit your needs, or use it as a reference in implementing your own.
Okay thx