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

I need to add force based on the angle I'm looking at the object.

$
0
0
Here, I'm using Unity's add force script from the tutorial. ____________ using UnityEngine; using System.Collections; public class MoveBox : MonoBehaviour { public float pushForce = 1000; void OnMouseDown() { rigidbody.AddForce(-transform.forward * pushForce); rigidbody.useGravity = true; } } __________ No matter where I'm looking at the object, (in first-person) it only adds negative force along the z axis (the blue arrow). How can I change this, so it will add force forward from where I'm looking at it.

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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