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

I need to add a force to an object based on the local vector of the object that is hitting it and not the world coordinates or local coordinates of the object being hit.

$
0
0
I have the following script attached the the "projectile" I thought that the "direction" variable take the vector3 of the owner of the script but it did not. I am a novice and I appreciate any help.`using UnityEngine; using System.Collections; public class Projectile : MonoBehaviour { public float power; private Vector3 direction; void OnTriggerEnter(Collider other) { direction = Vector3.forward; other.rigidbody.AddRelativeForce(direction * power); } }` Thanks!

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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