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

Adding Force to a Rigidbody through OnTriggerEnter

$
0
0
This is compliling correctly. The object this is attached to (a boomerang) will go through the object with this script. The object it is hitting is not set to a trigger, and has a rigidbody. I am getting no console errors either. I've also tried this with enemy.gameobject.rigidbody.AddForce and so on... No luck. Thanks in advance! using UnityEngine; using System.Collections; public class Enemy : MonoBehaviour { void OnTriggerEnter (Collider enemy){ if (enemy.tag == "enemy") { enemy.rigidbody.AddForce (8000, 2250, 0); Destroy (enemy.gameObject, 2f); } } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



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