Another collision detection query!
Me again!
I'm now refining my collision detection to make it sharper, but this is causing me a bit of an issue.
I have multiple spawning weapons and enemies, all generated from prototypes. When one collides with the other I need to know which weapon has hit which enemy, and then both weapon and enemy inflict and take damage upon each other.
Currently this is easy with the basic collision detection rules applied to the weapon and enemy actor, but as I find from the forums, more precise collision detection requires an additional, smaller actor placed with original actor (weapon or enemy) and its that that determines collisions. When a collision occurs I have figured out how to relay that it's happened back to the original actor, but I can't figure out how to determine what has hit it and then calculate how much damage should be done. From my previous query with range finders I now know how to allocate a unique id to any actors created to act as group, so I'm sure this can be utilised here again, but I can't figure out how to get relay the additional information.
Any ideas?
Best Answer
-
Socks London, UK.Posts: 12,822
@mysticjim said:
I can't figure out how to determine what has hit it and then calculate how much damage should be done.Just make some basic rules that say . . .
When hero collides with actor A change damage to damage + 10
When hero collides with actor B change damage to damage + 5
When hero collides with actor C change damage to damage + 32
When hero collides with actor D change damage to damage + 2. . . etc etc.
Answers
Hold on, I know what to do - I think. I've been going about this the wrong way, because I started with the actual weapon actor having a health attribute, and that being lowered with collision, I was still in the mindset that with my new system I need to detect the collision with my collision detector actor and somehow pass that back to the weapon actor. In fact, with this system the weapon actor is simply just an image on the screen, it's the collision detector actor that should have the health attribute, and has the rules within to know when it's been hit and what by, and most importantly, how much damage has been done. And when the collision detector's health reaches zero it needs to trigger the destruction of the weapon actor, then destroy itself.
Man, this is complicated!