Quantcast
Channel: Latest Questions by Ludus
Viewing all articles
Browse latest Browse all 14

How to detect if my rigidbody (with Triggers, no colliders) has been hit by a force?

$
0
0
My game has 2 types of baddies, normal ones that can be hit by bullets and have to navigate normally(normal colliders) and those which can also be hit by bullets BUT move through walls (use Triggers). At the end of every round a small explosion forces all objects back, problem being normal baddies fly back and hit the walls (good), while the others get pushed off the level and fly away indefinitely (bad)! For this explosion shockwave I edited a script in the awesome Detonator Kit. No matter what name/tag I give the shockwave the trigger based baddies simply can't detect being hit by this! I want the trigger enemies to die on impact of the shock wave, I can see it has to be the shockwave that tells them but I'm uncertain of a optimized way to do so. Script for reference; using UnityEngine; using System.Collections; [RequireComponent (typeof (Detonator))] [AddComponentMenu("Detonator/ForceMurphy")] public class DentonatorMurphy : DetonatorComponent { //This is a Force Script btw. private float _baseRadius = 50.0f; private float _basePower = 4000.0f; private float _scaledRange; private float _scaledIntensity; private bool _delayedExplosionStarted = false; private float _explodeDelay; public float radius; public float power; public GameObject fireObject; public float fireObjectLife; private Collider[] _colliders; private GameObject _tempFireObject; //Custom public int enemyLayer; // Layer enemies are on override public void Init() { //Go and use the baddie layer, since I only want to move them! enemyLayer = 1 detail) return; if (!_delayedExplosionStarted) { _explodeDelay = explodeDelayMin + (Random.value * (explodeDelayMax - explodeDelayMin)); } if (_explodeDelay

Viewing all articles
Browse latest Browse all 14

Latest Images

Trending Articles





Latest Images