Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

LittleFreak

Semi circle collition help.

This topic is 5295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can do ray collition and I can do radius collition. But how do I do a semi circle collition.(EX. Swing of a sword.. Detect every mesh that the sword hits.) Any tips?

Share this post


Link to post
Share on other sites
Advertisement
Why don''t you just check if the mesh is on the right side of the circle, (you can use a dot product for this I''m pretty sure) and then check for distance (radius). That should get you what you need. It''s just a 2-step process.

Share this post


Link to post
Share on other sites
I tried that it didnt work real well it works fine if the character is facing down a axis but when i try this when its on an angle like let say 45 degrees it will only take the top half and is on the extreme left of the swing.... Is it possiable to track a movement of 1 mesh (the sword) and return a linklist or something like that of all the meshs that the mesh goes through.. my question with that is tho is how do you determine the hit if a object hits a odd shaped objects.

Share this post


Link to post
Share on other sites
Here''s what you need to do as an exact formula:

Let v = the vector that represents the direction that you''re facing, or the middle of your swing.

Let u = the vector from the point of swing to the point you want to test.

if u dot v is > 0, then it is on the side of the circle representing your swing that you want.

THEN

if the distance between your centre of swing, and the point you are testing is less than the radius of your swing, then that point is getting hit.

There you go, that''s what you need to know. You might want to look up a good book about linear algebra and matrices. I''d suggest "Linear Algebra and its Applications, Third Edition" by Davic C. Lay.

Any questions, just write back.

Share this post


Link to post
Share on other sites
I almost forgot to say this. If the bounding boxes don''t intersect, then they aren''t going to hit at all. Also, if the bounding boxes interesct, then you''d probably want to test all of the vertices to make it very accurate. You could probably get by checking only every second vertex assuming that your model is fairly detailed, and not spiky.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!