Collisionobject screw up! (SOLVED)

Hi all!

I have a question…

Do i need to tell my script to move the collisionobject like my sprite?

I have a game object with a collisionobject that is 2 boxes and and 2 spheres. inside the game object i also have a script and a sprite.

firstly when i run the game the outlines/shading for the collision object is over the top of the sprite and secondly the collisionobject does not move like the sprite does!!!

what did i do wrong?

1 Like

Hmm, I’m not sure I understand. You have a game object with a script, sprite and a collision object with four shapes? What do you mean by “the outlines/shading for the collision object is over the top of the sprite”? Could you post a screenshot of your setup?

1 Like

strangely enough its not doing it on my work branch. I will be able to post a picture when im back from work.

but what you have said is correct, what i mean about the outline, is the yellow that you can see when sizing the box out.

this appears on top of my sprite when i launch my game.

You have probably checked the Physics debug checkbox in game.project.

1 Like

this is another example of the collisions not working how i expected (im sure its must be something im doing wrong)

i have 2 box collisions (static) that sit in the middle of the game (in this example) the plane also has a static collision box but they dont collide. they did when i used gravity to test.

1 Like

AHHHHH ok … i will try that! thanks.

1 Like

hi me again!!

my message above… i have a plane that has a static ( i also tried dynamic) collisions… and 2 edges (walls) that are static.
when gravity is applied the plane sits on the wall and thats fine, when i apply my movement script to it, the ‘walls’ seem to have no effect.

the plane goes go past them and does not interact, i cant figure out why?! do i need a script, or is there a way of using the collisions with gravity turned off?

thanks all.

1 Like

If a collision object is of type Dynamic it will be completely under the control of the physics engine (Box2D) and the physics engine will apply all forces, gravity etc and it will resolve all collisions. You can control the game object by applying forces to it.

If a collision object is of type Kinematic it will generate collision_response messages that you can react on in your on_message function and you need to resolve the collision yourself, just as in the Getting Started platformer tutorial. On the other hand control of the game object is easy since you can move it around simply through calls to go.set_position().

2 Likes

Have you read about groups and masks(http://www.defold.com/manuals/physics/#_group_and_mask)? If I understand correct, they are what sets the relationship between physics objects.

Edit:
I also think static is wrong for somehing that moves(your plane). From the manual -
Static objects These do not react in themselves, but any other object that collides with static objects will react. These are very useful (and cheap performance-wise) for building level geometry (i.e. ground and walls) that does not move. You cannot move or otherwise change static objects.
I would try to use kinematic on the plane, and handle the trigger response.

3 Likes

Thanks guys,

I did read through the groups and masks, they are set. I think its down to what @britzl has said, I will look at collision_responses and changing the plane from static to kinematic.

Advice taken on board and more reading and learning will commence.

Thanks again.

3 Likes