Basic Question about Objects

Hi everyone

i feel so stupid asking this but i cant get my head around how to do it and i know it will be simple.

Its a tank game where the tank can move in all directions so i havnt set any other automatisms other than the movement of the tank.

how do i get it so when my tank is in collision with an object it cant move through it, i tried adding path finding to tank and added path finding obstacle to object but it can still go through it, so i then tried making the object a platform which also doesn’t work, i just don’t get how to do it.

Guaranteed ill feel like a right mong when someone explains how to do it :slight_smile:

You have some options :slight_smile:

1 - Save object position and angle in variables, every frame. When collides with a wall, set the position to the previous one (note I save the data in variables after check the collision, other way you will check the actual position, not the previous one). This way you don’t get “vibrations”, but the Tank gets literally stuck until you move in a direction it doesn’t collide:

Conditions: Tank collides with Wall Actions: Do = Variable(OldX); Variable(OldY) to the position of Tank Do = Variable(OldAngle) to the angle of Tank

Conditions: No conditions Actions: Do = Tank.X() to the variable OldX Do = Tank.Y() to the variable OldY Do = Tank.Angle() to the variable OldAngle

2 - Use the action to separate objects (All objects >> Position >> Separate two objects). This action is easy to use, and the Tank will response even when colliding (you can move in diagonal right-down with a wall at right, and the tank will move at down), but you can get “vibrations”:

Conditions: Tank collides with Wall Actions: Move away Tank of Wall (only Tank will move)

3 - You can kill a fly with a bazooka too, with the Physics automatism :smiley: , just set the gravity to 0;0, and the walls as statics objects.

1.) Saving all the positions in variables will be extremely hard work as i have alot of objects

2.) If i use physics it doesnt act like a tank as it will run dwn a wall diagonally

3.) waaaaaat lol

You can save the values in object variables, this way every object will “remember” its last position :wink:

Actually, this was the point 3.). Anyway I’ve tested it, if you set the gravity (global Physics settings) = 0;0 there will be no gravity so the tank will not fall down, and it seems that the rotation is given by the 8-directions movement automatism, maybe I’ll check it again later :slight_smile:

There is an action called “Separate two objects”, you can find it in “All objects >> Position >> Separate two objects”. When a tank collides with a wall, separate both objects with this action, just that :slight_smile:

ahhh thankyou i will test a few of them nw :slight_smile:

thanks ever so much, im using the seperate both objects method as most objects i have events for anyway so it will be easy to implement and not too time consuming