H
Heropants
Guest
I'm creating what's essentially a top-down shooter and I'd like it if some objects bounced of others correctly. I found this code I placed in the step event mostly works, except that it has you input 0 if the object is hitting a vertical surface and 90 if it's hitting a horizontal surface.
This code works except that I have no idea how to to detect if it's hitting a vertical surface (where n should be = 0) or a horizontal surface (where n should be = 90). Does anyone have any ideas how I might detect that?
Thank you so much in advance for any help.
Code:
///bounce off full walls
if speed > 0.1 { //it's still moving
if place_meeting(x + lengthdir_x(speed, direction), y + lengthdir_y(speed, direction), obj_parent_full) { //comes in contact with a full wall
var v = direction; //angle they are traveling
var n = 0 for vertical walls, 90 for horizontal; //! I HAVE NO IDEA HOW TO TELL IT IF N should be 0 or 90
//final calculation
direction = 2 * n - v - 180;
}
}
Thank you so much in advance for any help.