|
Post by AppThing on Jun 16, 2014 15:18:10 GMT
Hi,
The Question: Q. Is it normal that a child collider should trigger damage on a parent Killable? and if so, is there a way around this behaviour?
The Scenario: I have two gameObjects in my test scene with the following hierarchy;
(Enemy) - EnemyArcher <RigidBody, Sphere Collider (Rad: 0.5), NavMesh Agent & Killable Script, EnemyController Script> -- Archer_01 (the animated, skinned asset) -- RangedWeaponRange <Sphere Collider (Rad: 7, IsTrigger), Triggered Spawner, disabled Renderer> -- MeleeWeaponRange <Sphere Collider (Rad: 0.75, IsTrigger), Triggered Spawner>
(Player) - Player <ClickToMove, Capsule Collider (Rad: 0.6), Killable Script (Attack Points:1), NavMeshAgent> -- PlayerWeapon <RigidBody, Box Collider, Killable (Attack Points:25)> ) - i.e. has no renderer
What is supposed to happen is that the Enemy "Follows" the player until the Ranged Weapon Collider Triggers, at which point he stops moving (moves to stay in range) and an "EnemyBow" gets spawned which in turn spawns arrows at the Player.
What actually happens is that when the Enemy RangedWeaponRange Collider hits the PlayerWeapon (which is about the same time as it hits the Player) then the EnemyArcher immediately takes 25 points of damage and is killed. :-(
Is it normal that a child collider should trigger damage on a parent Killable? and if so, is there a way around this behaviour?
many thanks.
|
|
|
Post by DarkTonic Dev on Jun 16, 2014 16:20:29 GMT
Yes, it's normal and that's the only way to create complex colliders. To fix it, you have to give the child collider a rigidbody as well. Make it kinematic.
|
|
|
Post by AppThing on Jun 16, 2014 20:07:48 GMT
great thanks, i'll try that in the morning..
|
|
|
Post by DarkTonic Dev on Jun 16, 2014 22:13:22 GMT
Any time.
|
|
|
Post by AppThing on Jun 17, 2014 14:57:12 GMT
Hi, This worked (mostly). What I am trying to achieve is: Whilst the Player Object is "in Range" i.e. an "onTriggerStay" equivalent, then an "arrow" gets fired at the Player, as soon as the player moves out of range the arrows stop (also the arrows self despawn after about 4 seconds). on the RangedWeaponRange GameObject there is a Triggered SpawnerTrigger Enter Event = true; Number to spawn = 1; Delay Wave = 1; Stop When Trigger Exit = true; Repeat Wave = true; Pause Before Repeat = 0.2; What actually currently happens is: - Player comes in range - one arrow appears in the PoolBoss and is fired at the Player (despawns after the appropriate time) - No other arrows are fired I can get the arrow to be re-spawned if I move the Player out of range and back in again. I must be missing something because I would expect the arrows to be re-spawned repeatedly every 1.2 secs until the "OnTriggerExit" occurs at which point it should stop. I'm pretty sure it must be something I am doing so will continue to dig and let you know, but I am posting here just in case you have a "ahh thats a common mistake you need to do X" moment??  thanks.
|
|
|
Post by DarkTonic Dev on Jun 17, 2014 16:16:22 GMT
I'm not sure why that wouldn't work. Did you try not repeating the wave and just making the wave of 1000 over 1000 seconds?
|
|
|
Post by AppThing on Jun 17, 2014 16:53:27 GMT
I just tried that and it did fire a few more arrows (5 appeared in the PoolBoss) but then it stopped :-( very wierd
The other strange thing is I created a listener for the spawner to try and debug it, but nothing is coming out of it..
|
|
|
Post by DarkTonic Dev on Jun 18, 2014 0:55:36 GMT
If that's the case, then I believe trigger exit is in fact occurring, whether it should be or not. Maybe a collision Unity bug? Did you try adding a script to log if/when trigger exit happens there on that same Game Object?
Unless you just didn't set up high enough limits on your item in Pool Boss...
|
|
|
Post by AppThing on Jun 18, 2014 9:08:28 GMT
hmm, so I threw a simple debug script onto the RangedWeaponRange Object listening for OnCollisionEnter/Stay, OnTrggerEnter/Stay/Exit etc and it gave me the following output: so... I can see a DEBUG OnTriggerEnter: Player (1) and several DEBUG OnTriggerStay: Player (733) but no DEBUG OnTriggerExit: Player separate (but linked) question, you mentioned about if i had set limits in the PoolBoss. Are you saying that if I have a Prefab placed in a PrefabPool I also have to add it to the PoolBoss because so far i haven't been doing this (but i do have Auto Add Missing Items checked)? just in case i missed a tick box or similar, here is the RangedWeaponRange Inspector Window: 
|
|
|
Post by AppThing on Jun 18, 2014 9:20:38 GMT
ok, so further to this it's definitely something to do with one of the scripts on the arrows themselves, if i create a simple cube, add a Timed Despawner Scirpt to it, it happily infinitely respawns... hmm.. Thanks for your time, I will let you know how i get on..
|
|
|
Post by DarkTonic Dev on Jun 19, 2014 0:01:18 GMT
ok let me know when you figure it out.
|
|