• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Need math code for Mirroring Angles!

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
Ok for my new so called "spell" i need some kind of math code to mirror an angle to make it look like it bounces of the things it hits.

Ok an example picture is needed i think ;)
attachment.php


Hope you all understand and please comment if you do. Thx
 

Attachments

  • Untitled-1.png
    Untitled-1.png
    344.2 KB · Views: 838
Level 14
Joined
Nov 18, 2007
Messages
816
JASS:
// pure pseudocode
local real ang = Atan2(GetUnitY(obj)-GetUnitY(inc), GetUnitX(obj)-GetUnitX(inc)) // obj is a static object, unable to move; inc is the incoming unit
local real sang = Atan2(inc.speed.y, inc.speed.x)
local real newang = bj_PI + (2*ang) - sang
    set inc.speed.x=Cos(newang)*inc.speed.amount
    set inc.speed.y=Sin(newang)*inc.speed.amount
two units colliding.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
if you have a x velocity and a y velocity you can do it like this:
JASS:
...
if IsPathable(x + xvel, y) then
    set xvel = xvel * -1
endif
if IsPathable(x, y + yvel) then
    set yvel = yvel * -1
endif
...
I hope you understand what I mean.
 
Status
Not open for further replies.
Top