Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

AddForce not working on Y

$
0
0
Hi, so I made an enemy that should jump at player when he is near "attack" range, I used rigidbody.AddForce to do that. When I add force x and z works perfectly but when I do y it doesnt do anything. Code: if (states == theState.attack) { if (Vector3.Distance(transform.position, player.transform.position) > 10f) { states = theState.run; agent.enabled = true; } transform.LookAt(new Vector3(player.transform.position.x, transform.position.y, player.transform.position.z)); agent.enabled = false; //Buggy Part rigi.AddForce((player.transform.position.x - (transform.position.x)), 10f, (player.transform.position.z - (transform.position.z)), ForceMode.Impulse); agent.enabled = true; StartCoroutine(noVelocity()); states = theState.run; }

Viewing all articles
Browse latest Browse all 1264


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