Physics collisions
#1
Posted 24 April 2012 - 07:07 AM
1) I am wondering how to make two objects collide (and interact accordingly - like bounce) which arent in the same group through using a collision event - I can't seem to find a function to do this.
2) Is there a way use the collision events for collisions between objects with fixtures and objects without fixtures? Ortherwse whats a good way to test these? collision_circle etc. or place_meeting?
#2
Posted 24 April 2012 - 06:49 PM
#3
Posted 25 April 2012 - 02:34 PM
As for number 1 then, anyone else care to comment? Is this supposed to be possible? The manual makes it sound so.
I guess I need a Box2d equivalent of move_bounce_solid() but for two objects with fixtures which are not in the same collision group.
#4
Posted 28 April 2012 - 04:33 PM
#5
Posted 02 May 2012 - 09:34 AM
Edited by vann, 02 May 2012 - 11:34 AM.
#6
Posted 02 May 2012 - 02:58 PM
Take a look at the game first to make sure that's the type of physics you are looking for. When you bounce into what I call the virus - both you and the virus float away from each other.
First off in the collision event:
while (place_meeting(x, y, other))
{
x -= lengthdir_x(1, direction);
y -= lengthdir_y(1, direction);
}
move_bounce_all(true);
Then add the same thing in the collision even BUT make sure you click on the radio button "OTHER" at the top.
Then step 2:
My code only works if you are not holding down what ever button you coded in to make the player move forward. So what I did was add a variable called "cannotmove" set it 0 on creation then set it to 1 in this collision....
if cannotmove = 0
{
while (place_meeting(x, y, other))
{
x -= lengthdir_x(1, direction);
y -= lengthdir_y(1, direction);
}
move_bounce_all(true);
cannotmove = 1;
alarm[0]=room_speed*1.5;
}
Then I made an alarm[0] that puts cannotmove = 0 after 1.5 seconds.
THEN in the code where I press "UP" to move forward I made sure to check first to see what the value of cannotmove is
if cannotmove = 0
{
speed = 1;
etc
etc
}
I wouldnt say my code is perfect by any means but for my game and its theme it works fine enough for me.
Edited by ChefDavid22, 02 May 2012 - 03:00 PM.
#7
Posted 05 May 2012 - 05:13 AM
Back on topic: if your trying to make it roll and bounce that could take some experimenting.
#8
Posted 06 May 2012 - 02:33 AM
Thanks for you reply but this isn't what I am looking for, I am wondering how to envoke physics collisions from box2D in the collision event, specifically how to do this without having two objects in the same collision group.
In the manual the caption for the third image in the entry for physics_fixture_set_collision_group(fixture, group) says:
These balls belong to different collision groups and they collide based on their collision event
What I can't work out is how to make them collide and react accordingly (using the physics engine) in their collision event.
Are any of the devs able to help clarify this, seems noone else has needed this functionality?
Thanks for any further help
#9
Posted 06 May 2012 - 04:23 AM
#10
Posted 16 May 2012 - 12:06 PM
These balls belong to different collision groups and they collide based on their collision event
The picture which accompanies the third image specifically has a ball from collision group -2 colliding (ie, bouncing) with a ball from collision group 1.
Can someone please explain how to acheive this, or put me out of my misery and tell me its actually not possible (yet?)...
Thanks again.
#11
Posted 16 July 2012 - 02:59 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











