I was trying to make an object bounce off walls. It works perfectly at certain angles but at others it really chokes up and the object starts going off at strange angles. I want it to move along the wall one tile before bouncing off. If I ever move on to pixel movement I hope this problem will stop. I so far have not been able to pinpoint the problem. I believe it has to do with my angle rotation because in every wall rotation such as up down left right there is an angle that works and one that starts the object off in a strnage way.
Note: Head on collisions are supposed to have it bounce back head on or at an angle. That is why that case is there.
oldoldloc = oldloc
oldloc = loc
//A = wall
//oldloc = current location
//oldoldloc = old location
if(isturf(A) && gtype != "impact")
A = A.loc
var/entangle = get_dir(oldoldloc,src)
var/bounce = turn(entangle,180)
if(bounce in list(NORTH,SOUTH,EAST,WEST))
bounceang = turn(bounce,pick(45,0,-45))
bounceang = turn(bounce,-90)
// world << entangle
// world << bounce
// world << bounceang
// world << turn(bounceang,-45)
// world << "NW:[NORTHWEST]"
Copyright © 2015 BYOND. All rights reserved.