Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
Collision in space

Registered User
2011-05-21 14:21:30

Hi everybody, hi Niko,
I'm making a game in coppericht and I have problem with collision detection. In coppercube I made few sceneNodes: planets and ship. Every planet has got two animators: rotate and fly in the circle and ship has got rotate animator. I have a skybox too, prepared in copperlicht.

This is first version: (8mb models and textures may have a long time load).

I don't know how to do collision detect between ship and planets. Which functions uses etc. Thanks in advance. Greetings.

Registered User
2011-05-21 15:48:15

I'd suggest to use the bounding box of the ships. Every scene node has a function named getTransformedBoundingBox(). That one again has a function intersectsWithBox(), which you can use to test the collision between two ships. Like

var box1 = ship1.getTransformedBoundingBox();
var box2 = ship2.getTransformedBoundingBox();
if (box1.intersectsWithBox(box2))
// do something

You can even test the collision of lines (for shooting maybe?) with this, and it is quite fast: box1.intersectsWithLine(startpoint, endpoint).

For planets, I would test if one of the edges of the box (or maybe just the center?) is within the radius of the planet.

Registered User
2011-05-21 16:47:42

Fantastic and pure simple :D Big thx!

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "I?ternational" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact