How to find a good point on an IAnimatedMesh to shoot at
How to find a good point on an IAnimatedMesh to shoot at
Currently when one of my agents shoots at another agent they simply shoot at the centre of the enemy agent's bounding box. Unfortunatly on some of my agents this point is not actually within the Mesh, so the shot misses all the time.
So how can i get a good point on the mesh to shoot at? Basically want some point that's about in the centre of the mesh, and it would be good if there was some general way to find this so i didn't have to define a different point for each agent.
So how can i get a good point on the mesh to shoot at? Basically want some point that's about in the centre of the mesh, and it would be good if there was some general way to find this so i didn't have to define a different point for each agent.
-
- Posts: 395
- Joined: Fri Apr 08, 2005 8:46 pm
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
Re: How to find a good point on an IAnimatedMesh to shoot at
pfo:
saku: i really don't want to make the path of the projectile more complicated, just want to have a target on the enemy so that if it's shot at that point and the enemy doesn't move it will hit, cos otherwise it's making it impossible to hit one of the enemies when it's facing side on.JP wrote:Currently when one of my agents shoots at another agent they simply shoot at the centre of the enemy agent's bounding box.
you could always remember which vertex number is the 'heart' of your enemy and always aim a set distance behind it, or use a bone for the heart's position, or like Saku said make each bullet aim with a random offset. another idea, (which you probably wont like) who says the bullet needs to actually hit the mesh? im intersecting a line with a sphere for my bullet collision because its faster
-
- Posts: 395
- Joined: Fri Apr 08, 2005 8:46 pm
Code: Select all
s32 frame = AnimatedMeshSceneNode->getFrameNr();
IMesh* mesh = AnimatedMesh->getMesh(frame, detail, start, end);
s32 m, n = mesh->getMeshbufferCount();
for(m = 0; m < n; ++m)
{
IMeshBuffer* buffer = getMeshBuffer(m);
// do your business
}
Well that worked, but not for the shooting..... as summing up and taking the average of the vertices points doesn't necessarily give a point within the mesh... In one example it gave a point between the agents outstretched arms, and so whent he agent was side on the shot didnt hit the agent...
any other suggestions? :s
any other suggestions? :s