Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

How to set velocity of Rigidbody without changing gravity?

$
0
0
I feel as if this shouldn't be happening. But when I set the velocity of my rigidbody using a Vector3 like the following code is showing, it somehow messes up the gravity and the cube object starts floating down really slowly. rb.velocity = Vector3(xmove, rb.velocity.y, zmove); Surely this shouldn't change the vertical velocity of the Ridgidbody at all, but it still does. #pragma strict var speed: float; private var xvel: float; private var zvel: float; private var rb: Rigidbody; function Start () { rb = GetComponent.(); } function FixedUpdate () { xvel = Input.GetAxis("Horizontal"); zvel = Input.GetAxis("Vertical"); rb.velocity = Vector3(xvel * speed, rb.velocity.y, zvel * speed); } That's the full code attached to the player. The reason I'm not using forces is because I want the player to be more responsive in its movement.

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>