Moving Object Sliding Along Wall Not Random
#1
Posted 01 February 2010 - 10:24 AM
My problem is that the bombs collide with the wall and just slide along the wall instead of bouncing off it in a random direction. I have tried setting the bombs to bounce off the walls but its not random enough. I just want the bombs to bounce randomly off walls to make it more difficult.
Thanks,Novice Game Maker
#2
Posted 01 February 2010 - 11:46 AM
If the collision is to the right or left, execute this:
vspeed = irandom_range(min,max);
Replace min and max with the min/max possible values. If you don't use GM8, use this code instead:
vspeed = floor(random(2*max))-max;
The min value will automatically become the -max (i.e. if you choose 4, the min becomes -4).
For top/bottom collisions, just replace yspeed with xspeed:
hspeed = irandom_range(min,max);
hspeed = floor(random(2*max))-max;
And there. You've got random bouncing. But again, I suggest you don't do this. It could prove to be quite frustrating. Just make the bombs bounce off.
Edited by jaychant, 02 February 2010 - 05:10 AM.
#3
Posted 02 February 2010 - 03:39 AM
Well, I don't recommend "random" bouncing because it's confusing to a player and can be very frustrating. However, if you want it to be "random" (I assume you mean a random direction) then do the following:
If the collision is to the right or left, execute this:yspeed = irandom_range(min,max);
Replace min and max with the min/max possible values. If you don't use GM8, use this code instead:yspeed = floor(random(2*max))-max;
The min value will automatically become the -max (i.e. if you choose 4, the min becomes -4).
For top/bottom collisions, just replace yspeed with xspeed:xspeed = irandom_range(min,max);xspeed = floor(random(2*max))-max;
And there. You've got random bouncing. But again, I suggest you don't do this. It could prove to be quite frustrating. Just make the bombs bounce off.
I am sorry but i dont know how to tell if a colision is to the left right top or bottom... could you let me know please
#4
Posted 02 February 2010 - 03:44 AM
#5
Posted 02 February 2010 - 05:08 AM
Use this action before changing horizontal speed:
Put in "hspeed" for the value and check the Relative box.
If that returns true, you hit a wall vertically. So under this, set the horizontal speed:
to "irandom_range(min,max)" or "floor(random(2*max))-max" if you are not using GM8. Be sure to replace max and min with their respective values. Also, if you reverse the vertical speed, move that action to here.
Use the Else action for the horizontal collision:
And set the vertical speed to "irandom_range(min,max)" or "floor(random(2*max))-max" (be sure to replace max and min with their respective values). If you reverse the horizontal speed, move that action to here.
Edited by jaychant, 02 February 2010 - 05:19 AM.
#6
Posted 02 February 2010 - 05:18 AM
#7
Posted 02 February 2010 - 05:20 AM
umm sliding along wall still.. i put the circle command in the create of bomb and the else in collision event
No, put them both in the same event, the collision event. These are conditionals. Using "else" by itself will do nothing.
#8
Posted 02 February 2010 - 05:24 AM
so can i only set them to move diagonally off walls is that the only way i can not make them move along walls?
Edited by enak101, 02 February 2010 - 05:25 AM.
#9
Posted 03 February 2010 - 05:04 AM
Alternatively, reverse horizontal/vertical direction in the places I indicated.
Edited by jaychant, 03 February 2010 - 05:04 AM.
#10
Posted 03 February 2010 - 07:31 PM
#11
Posted 03 February 2010 - 08:49 PM
sorry if i didnt understand yous the best pretty new to it still. Now to powerups hehe
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











