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

AddRelativeForce to another object

$
0
0
Hi Guys, This might be really simple but it's had me stumped for about an hour now. I am trying to create a fan, which blows other games objects in which ever direction it is facing. Simple enough but I can't work out what I m doing wrong. This script; var force : float; var contact : GameObject; var myPos : Vector3; function FixedUpdate() { myPos = gameObject.transform.position; } function OnTriggerStay(other:Collider) { if(other.gameObject.tag == "Player") { contact = other.gameObject; contact.rigidbody.AddRelativeForce(Vector3.up * force * Time.deltaTime); } } Adds relative force based on the orientation of the object itself, not the direction of the fan. Can some clever folk please advise, many thanks in advance!

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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