Hi!
I have a character with a sword. The sword is a child object of the character.
I can now turn it off and on (the render and the collision).
But the sword doesn’t respond to collision scripts! It does collide, character wobbles. But it should destroy the character and itself.
See the code and the hierarchy:
I really need this to work so that if a sword runs into a shield the character will stagger/be stunned for a second or so.
Thanks to anyone who can help, I thought it should work :s
I tried spawning the shield and the sword. But the objects have to be kinematic in order to stick to the animation.
And when they are, they don’t detect other spawned objects and cannot collide.
Has anyone tackled simple melee and blocking combat at all?
It seems pretty basic, but it’s impossible for me to get it working.
Okay, I added another box to the model as a child.
Without the fancy turn off/on script. Just a collision detection.
And it doesn’t work.
Any ideas?
cjow
September 19, 2012, 11:00am
4
I may have missed something here. But if you just want to destroy the parent of an object you can do:
Destroy(transform.parent.gameObject);
This will destroy all the children of that parent as well.
Hi, thanks for the response.
But I use the destroy function to simply check if the object is doing anything at all.
What I want is to send a message so that a function is activated in the parent.
So if the sword hits a shield, the parent (the character) will be stunned for a while.
Oh yess, it’s not about to destroy the parent.
But to activate a function in the parent if the child collides with something.
That’s the thing that doesn’t work.