Collision help

Started by clown611, March 18, 2017, 02:34:16 PM

Previous topic - Next topic

clown611

Hi I been trying to figure out this by myself but cant manage to figure it out. To pick up objects in my game I have implemented the collisionlistener, it worked out fine. But now when I want to make my planets solid I have tried to check when im colliding with them. But the listiner is only responding when the camera hits the object.

Object3d spaceship = a loaded 3ds modell
Object3d earth = a loaded 3ds modell

spaceship.setCollisionMode(Object3D.COLLISION_CHECK_SELF);
earth.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);

earth.addCollisionListener(this);


Here is a video so you can see what I mean.

https://youtu.be/dmrYE05Q3MA


clown611

well well well after reading up some I checked the code I used your code from the car example to follow my spaceship wish included

world.checkCameraCollisionEllipsoid(delta.normalize(), new SimpleVector(20, 20, 20), len, 3);

After I realised this I knew had to change the code or check if anything touched the spaceship. Since im lazy I solved it using checkself and went on from there. Still trying to figure out the best way of making an object solid. If you guys have any tips please give me some.

EgonOlsen

I'm not sure what you mean!? Is it solved now or not?

clown611

I thought I solved it but I didnt. Like I think I dont really understad the basic of the collision because sometime I can make it work and sometimes not. So basically I want to make a sphere solid. The way im using is adding a adding a listiner to earth and then putting

world.checkforcollision(spaceship.transformedcenter, earth.translation, 5)

You should sell leasons or make a course because I would pay you by the hoar for some explaining.

EgonOlsen


clown611

ye I read it and I tried to read all of the exampels. But I have a hard time understanding how to detect the whole sphere and not only the center and even how I shall manage to make it solid after I detect the whole sphere.

EgonOlsen

Collisions in jPCT are always bounding "object" (ray, sphere, ellipsoid) agains actual geometry. In your case, the planet is the actual geometry. There's no need to make it "solid" or anything. It already is. The sphere/ellipsoid that you define in the method call is the bouding object for the colliding entity (a moving ship, the camera etc.(, not the collision's target (your planet).
Then you call the collision methods (in your case, most likely ship.checkCollisionEllipsoid(...)) and you should be fine. You might have to adjust the collideOffset setting in Config, because it usually isn't suitable for large scales as it is by default.

clown611

I will try hard after school.

clown611

I just have to confirm what I shall write in the spaceship.checkforeppliode() to check the whole sphere. shall i search for the translation? or how can I check the whole sphere?

EgonOlsen

You don't. That's what I tried to explain. The collision happens betwenn an sphere/ellipsoid as an approximation of your ship with the actual geometry of your planet. There's no need to find a matching sphere for the planet, it's defined by its very own geometry already.

clown611

ok im starting to understand how I shall use it. The main problem was the sphere I loaded, I dont know because of it's size or what it is. I played around with some primitives and it worked fine. Tomorrow I will play around with the offset or just make a new sphere. Thanks for the help, still i recomend you to start a course on udemy och sell som favors @ fiverr. You can earn som gold.

clown611

Hi again it was no problems with the sphere I just needed to read your comments a few times and some trial and error. Now the collision works fine.