• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Need help with angles

Status
Not open for further replies.
Level 11
Joined
Sep 12, 2008
Messages
657
Hey everyone, i was playing Pudge wars..
and i saw that when you hit a wall for example with the hook,
it caculates diffrences in angles, and shoots it towards the next angle.

for example:

a hook is sent toward a wall, the wall is flat, (180 degrees ______),
the hook hits the wall, and the hook does this:

set angle = angle + 180, (makes him turn back) + ~70.
that makes it add a bit wide angle, and allso turn back.
but thats only flat.. how do i caculate every diffrence in the wall?
(if the wall is 100 degrees, 171 degrees, 50 degrees, just in a easy way)
and in Vjass/Jass if you could.

thanks in advance. (this is just out of curiosity.)
 
Level 10
Joined
Jun 26, 2005
Messages
236
Okay, just use this formula I derived:

JASS:
  function GetAngleOfReflection takes real incidence, real tangent returns real
    return 2*tangent+180-incidence
  endfunction
What you do is make sure the wall is a unit, not a doodad, and then

JASS:
call GetAngleOfReflection(GetUnitFacing(projectile), GetUnitFacing(wall))
EDIT: Made it degrees, not radians.
 
Last edited:
Status
Not open for further replies.
Top