hgkjfhfdsj
Active Member
- Reaction score
- 55
im having trouble with the maths behind bouncing projectiles.
my code so far:
what my code is supposed to do is flip the angle (produced from the angle of contact) to the direction that is closest to it (a < 45 from direction). the problem with this is that it assumes the object the bounce occurs is a square. eg
========
a ?
?
"|" = projectile
"=" = wall
if a < 45 then the projectile will bounce north-westly which goes right through the wall (it should be bouncing south-eastly to avoid going through the wall).
random pic if it helps
[/IMG]
anyone know a better math than this. dumb it down for me if possible (terrible in maths )
if u need the whole code or happen to need a demo map please tell me
my original aim for this code is a jass version of pudge war's meat hook. (not that this info will help)
thanks
my code so far:
JASS:
function Data_bounce takes integer this returns nothing
local real a = RAbsBJ(udg_angle[this]*bj_RADTODEG)
if 2*a< 90 or 2*(180-a) < 90 then
set a = udg_angle[this]
if a> 0 then
set a = bj_PI - a
else
set a = -a - bj_PI
endif
set udg_angle[this] = a
else
set udg_angle[this] = -udg_angle[this]
endif
endfunction
what my code is supposed to do is flip the angle (produced from the angle of contact) to the direction that is closest to it (a < 45 from direction). the problem with this is that it assumes the object the bounce occurs is a square. eg
========
a ?
?
"|" = projectile
"=" = wall
if a < 45 then the projectile will bounce north-westly which goes right through the wall (it should be bouncing south-eastly to avoid going through the wall).
random pic if it helps
anyone know a better math than this. dumb it down for me if possible (terrible in maths )
if u need the whole code or happen to need a demo map please tell me
my original aim for this code is a jass version of pudge war's meat hook. (not that this info will help)
thanks