Custom Physics Needed

Hello! So, I don't use the built in physics engine in GameMaker because, firstly, I don't need it for much. Secondly, I want to have as much control over my code as possible.

So, when the player breaks something or when the player dies, they emit a couple objects that move outwards, rotate, and fall to the ground. I have it to stop moving entirely when they hit a solid object, such as the floor.

If the objects are too close to walls, however, they will stop, since walls are also solid. This gives a weird effect where the objects will just float in the air.

Also, if the objects happen to spawn within a wall, what sort of code could make them move to get out of the walls?

One last question: I have an object that falls that has a peculiar collision mask, and when it stops, it will stand straight upright. Imagine if you dropped a pencil and it just stood upright instead of rolling onto its side. How would I do something like this?

Thanks in advance!
 

kburkhart84

Firehammer Games
I'd recommend you do separate object collisions for walls instead of floors. This way, if it is a floor, you can make it bounce or stop, but if it is a wall, you do bounce and no slowdown(or less than the floor).
 
I'd have to see your code to figure out the problems. But one quick thing you could do to keep something from spawning in walls (place this in create event of spawned object):
Code:
while (position_meeting(x,y,WALLOBJECT)){
    //something to move out of the wall
    //I don't know how you spawn these objects (if they are placed randomly, or within certain boundaries)
    //One solution:
    x+=1; //move right until out of the wall
    //Another solution:
    y-=1;//move up until out of wall
    //Another:
    x=random(room_width);
    y=random(room_height);//jump to random place in room until not in wall
}
Just use whichever piece is best for you, and you can tweak it to your needs.
 
Top