W
WimpyLlama
Guest
I need the functionality of move_bounce_all, but better. I would like to be able to control the bounce and use the proper angle of reflection to bounce in the correct direction. I've been trying to figure this out for a few days now, and this is all I got.
The problem with this is a lot of things. 1: Bouncing doesn't work on the corners of the walls. You just phase through. 2: If you hold yourself up to a wall long enough, you clip into it. And 3: Setting down walls is very restricting now. The bouncing only works on walls that haven't been stretched or only ones that have been stretched horizontally. If they're stretched vertically, you just phase through.
Does anyone have a fix for this? If so, that'd be amazing! Thanks.
GML:
//X and y collision
var collideInst = instance_place(x + lengthdir_x(speed, direction), y + lengthdir_y(speed, direction), oWall);
if (collideInst != noone) {
//Get wall angle
var wallAngle = collideInst.image_angle;
//Get wall bounding box
var wallLeft = collideInst.x;
var wallRight = collideInst.x + sprite_get_width(collideInst.sprite_index);
var wallTop = collideInst.y;
var wallBottom = collideInst.y + sprite_get_height(collideInst.sprite_index);
//Add to wall angle if hitting the sides
if ((bbox_right >= wallLeft or bbox_left <= wallRight) and
(y > wallTop and y < wallBottom)) wallAngle += 90;
//Bounce away
motion_set((2 * wallAngle) - direction, speed);
}
Does anyone have a fix for this? If so, that'd be amazing! Thanks.