Answer the question
In order to leave comments, you need to log in
Character in unity flies off stage?
I am learning the Unity 5 engine. When I insert the move script
public class FPSInput : MonoBehaviour {
public float speed = 6.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float deltaX = Input.GetAxis ("Horizontal") * speed;
float deltaZ = Input.GetAxis ("Vertical") * speed;
transform.Translate (deltaX, speed, deltaZ);
}
}
Answer the question
In order to leave comments, you need to log in
at least you need to multiply the delta on the update by Time.deltaTime - to make it smooth.
Otherwise, it turns out that you are attaching such a very sickly speed there.
https://docs.unity3d.com/ScriptReference/Time-delt...
read what it is.
well, so that it takes into account colliders correctly - Daniil Basmanov correctly advises you to move through physics
, but with huge values \u200b\u200b- even an honest miscalculation will not help) "push" through the collider or begin to behave inappropriately
Translate ignores colliders, if you want to move in physics use AddForce or MovePosition .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question