Monkey Collision library
Home › Forums › TimelineFX Module › Monkey Collision library
- This topic has 5 replies, 2 voices, and was last updated 11 years, 4 months ago by
Htbaa.
-
AuthorPosts
-
July 8, 2014 at 1:15 pm #5239
HtbaaParticipantHi,
I’m implementing your collision library and so far it seems to work fine, but when I use a tlCircle for both my Spaceship and Bullet class I get an out of bounds error when using the IsColliding() method of the tlCollisionResult class.
The line of code the debugger sends me to is at line 1357 of collission.monkey (it’s the BoxCollide method of tlCircle). Inspecting the object it seems the normals array of the tlCircle object is empty.
Changing either Spaceship or Bullet to use Box (e.g. Spaceship uses Circle, Bullet uses Box or vice versa) then I’m not getting the out of bounds error. For usage I looked at your WebInvaders example.
Or shouldn’t I call tlBox.BoxCollide(tlCircle)? Which kinda makes sense now I think about it. A general Collide(tlBox) method would be nice I think. It can try to cast the given tlBox to see if it’s a circle or something else and then call CircleCollide(). Knowing this I can work my way around this. But would like to know if I’m right about it and going the right way with this :).
July 8, 2014 at 1:54 pm #5240
peterigzKeymasterHey, I’ll take a look tonight, I see that I’ve omitted examples of using the collision code, I do have a few so I’ll upload them tonight. This is a conversion of the Blitzmax version which had a CheckCollision function that would use casting as you mentioned, but I probably didn’t convert it because callbacks were involved. You have to implement callbacks differently in Monkey so as a result I didn’t implement few features of this collision system yet (like quadtrees for example), but I can’t see why I couldn’t make a checkcollision function that just returns a tlCollisionResult.
Will let you know how I get on 🙂
July 8, 2014 at 2:02 pm #5241
HtbaaParticipantCool! After doing the right collision checks I no longer have this error, so I was simply using it the wrong way.
When compiling I got some errors where variable casing didn’t match. For example AngleDifference() in math.monkey the casing of the parameters doesn’t match the usage inside the function body. Could be that I’m using Strict for my project though.
I’m currently using CheckRayCollission() to see if something is in range and then fire. But I think WithinFieldOfView() would be a better fit for it. My question is though what is the FOV parameter? Is it distance or an angle, e.g. 45deg view angle?
July 8, 2014 at 4:40 pm #5242
peterigzKeymasterFOV would be an angle, so the arc to check within. The direction is the way the observer is facing, so it will check either side of the direction. So if FOV is 45, then it will check 22.5 deg to the left and right of the direction. This is infinite though so you might want to put a separate distance check if needed.
I should update the module so it uses strict really, not sure why I didn’t!
July 8, 2014 at 9:45 pm #5243
peterigzKeymasterI’ve just updated the library and implemented CheckCollision and PreventOverlap functions. I added a couple of examples to the example folder as well, see CheckCollision.monkey for an example of use, it’s pretty straight forward 🙂
July 18, 2014 at 1:43 pm #5247
HtbaaParticipantSorry for my late reply, I seem to have missed the update e-mail… I just updated to the latest version which also works fine with Monkey X 79e (I guess Mike changed the usage of Public and Private to match the way it’s used in BlitzMax). CheckCollsion() is really useful!
Did find another typo (capitalized letter), but can’t seem to find where I changed it. Believe it was a parameter called Layer.
Thanks for clarifying the FOV thing. Would make my ‘simulation’ a lot more real than when using a ray collision check.
Thanks for the updates!
-
AuthorPosts
You must be logged in to reply to this topic.