GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2016-03-31 16:03:52

Shadowblitz16
Member
Registered: 2016-01-30
Posts: 3

division by zero in refection script

can someone help me
my script seems to be giving me a division by zero error
I got the formula from a irc and I don't know really know how it works

Expand///move_reflect(obj)
vx = argument0.x
vy = argument0.y
lx = lengthdir_x(argument0.speed,argument0.direction)
ly = lengthdir_y(argument0.speed,argument0.direction)
dx =  2 * (vx * lx + vy * ly) / (lx * lx + lx * lx) * lx - vx
dy =  2 * (vx * lx + vy * ly) / (lx * lx + lx * lx) * ly - vy
motion_add(point_direction(vx,vy,dx,dy),argument0.speed)

I'm trying to make an alternative bounce script since the move_bounce functions are buggy and don't work right

Offline

Board footer

Powered by FluxBB