- Home /
velocity change?
i'm tring to find my velocity but its not accurate?
function OnCollisionEnter2D(coll: Collision2D){
var myVelocity = rigidbody2D.velocity.magnitude;
Debug.Log(myVelocity);
if(coll.gameObject.tag == "ground"){
// if(myVelocity > 4){
// gameObject.SendMessage.();
// }
}
}
what am i doing wrong?
Please format your code, I can read it but people who come here for help might not be able to. Once you format it, I'll help.
How do you know it is not accurate? What does the Log output and what do you think it should output ins$$anonymous$$d? velocity.magnitude is the way to get the velocity of a rigidbody.
$$anonymous$$yRigidbody.velocity.magnitude gets the speed of a Rigidbody, not the velocity. Your velocity is accurate, the numbers you see in console are just a rounded off version of a much more accurate number.
Your answer
![](https://koobas.hobune.stream/wayback/20220613135547im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Velocity powered rigidbody on a moving platform without parenting. 3 Answers
[Solved] How to shoot an object in front of the player? 1 Answer
How do I accelerate particles in Shuriken? 1 Answer
Problems about prefabs and velocity affected by scripts 0 Answers
How to calculate the speed and direction to intercept with a target 1 Answer