Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

AddForce is inconsistent

$
0
0
i want my player to slide down a slope fast enough to land on the other platform. ![alt text][1] Problems: 1. I tried using addForce and also changed the velocity of x directly but they don't always give me the same result every single time. The player would land in different places. var shootDirection : String; var force : int = 10000; function OnTriggerEnter (col:Collider) { if( col.tag=="Player" ) { if( shootDirection=="left" ) { Global_Cache.playerTransform.rigidbody.AddForce(Vector3(-force, 0, 0)); } else if( shootDirection=="right" ) { Global_Cache.playerTransform.rigidbody.AddForce(Vector3(force, 0, 0)); } } } 2. And also, when the player moves i adjust the x velocity to 5 or -5, but when he slides down i want this velocity to work accordingly to the force of the slide. What happens now is if i hold down the left arrow button the force is ignored and player walks instead of being shot across the slope. [1]: /storage/temp/15152-img.jpg

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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