I cut-n-paste pieces of the collision demo code into the tech demo, to make the fireball shoot a node, rather than the map. My objective was to be able to target a node (the jumping or running characers) and have the fireball hit them, rather than go through them to the wall/floor. So far it is somewaht successful.
I was able to do this, but not sure I am doing it right. It seems that I have to know the mesh used to create the node, to be able to find if my camera is looking at an intesection with the node.
Question: is there a way to get the mesh used to create a node I programmatically select?
Question: is there a better way to target (determine the impact point)?
Also, the way the impact works in the tech demo, it targets the impact point, then animates to it. If I have targetted the running node, the node continues to run while my fireball heads to its destination and blows up there ... not when, and if, it actually intesects the node.
It seems that the fireball should have collision detection on its way to its end point, to better implement this ... should I try adding that? Or is there a better way to do that?
Looking to more advanced targetting, if I wanted a "homing missile" ... how would that be implemented? My initial thought would be to do something similar to how the impact works now, but have it go halfway, then retarget, halfway, retarget, ...repeat until it hits the target or colides with something else.
Thanks!
Building on tech demo - targeting a node and smart targeting
Is this more an advanced topic?
Still looking for some answers ....
Thanks,
Thanks,
Your best solution for hitting the characters and stuff is to do real physics.
So when you shoot a fireball you add an entity that you keep track of it. You keep track of its position and velocity. Each frame you use the time delta to determine how far to move the fireball. You also make a line from the old position to the new one and use that to test collisions against the level and the characters.
As far as getting the mesh out of a node, you don't really need to. What you can do is when the node is created you generate the triangleselector and then assign it to the node (setTriangleSelector). Then when you do collision detection you can grab the triangle selector out of any node with getTriangleSelector
And as for a homing missle it's the same construct except that every frame you'll be changing the velocity of the missile/fireball. Really you'd be changing its acceleration but to simplify it you just change the velocity.
You can it by doing:
The missle will then fly right at the target no matter where the target is. Like I said, this isn't realistic. Real missiles have to accelerate to change their velocity and they have a max acceleration and therefore can't hit a target no matter where it is (the missle may miss because it had to turn too much).
So when you shoot a fireball you add an entity that you keep track of it. You keep track of its position and velocity. Each frame you use the time delta to determine how far to move the fireball. You also make a line from the old position to the new one and use that to test collisions against the level and the characters.
As far as getting the mesh out of a node, you don't really need to. What you can do is when the node is created you generate the triangleselector and then assign it to the node (setTriangleSelector). Then when you do collision detection you can grab the triangle selector out of any node with getTriangleSelector
And as for a homing missle it's the same construct except that every frame you'll be changing the velocity of the missile/fireball. Really you'd be changing its acceleration but to simplify it you just change the velocity.
You can it by doing:
Code: Select all
vector3df d = target->getPosition() - missle->getPosition();
d.Normalize();
d *= missleSpeed;
missleVelocity = d;
If you simply want to do instant-speed shooting (will be faster than real physics, though obviously less realistic unless it's a sci-fi game with lasers, etc) create a ray along the Z (front) axis of the camera and use the ISceneCollisionManager to get the first node that ray hits.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars