Checking if the unit is leaning towards the blast circle

Gwafu

Active Member
Reaction score
12
In the picture attached to this post, there are four units (red dots), and a circle, and a point (black dot).

The point is the point where the spell is targeted.
The circle is the Area of Effect of the spell.
Unit 1 is inside the circle but is not facing the point.
Unit 2 is outside the circle but is not facing the point.
Unit 3 is outside the circle and is facing the point.
Unit 4 is outside the circle but is not facing the point.

Basically, the spell I made was some kind of wind magic which knockbacks enemy units inside the target area, and it seems boring. So I decided to add an effect where enemy units facing through the circle will be Cursed. The problem is, I don't know how to check if he is facing the circle (if it is inside the circle, the unit will only be affected when he is facing the point).

So, in the picture, units 2,3, and 4 are affected while unit 1 isn't.

Thanks in advance!
~Gwafu aka supertoinkz
 

Attachments

  • Base.png
    Base.png
    13.9 KB · Views: 238

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Trigger:
  • If ((Facing of (Picked unit)) Equal to (Angle from (Position of (Picked unit)) to (Target point of ability being cast))) then do (Do nothing) else do (Curse unit)

Are you looking for something like this?
 

Sajin

User title under construction.
Reaction score
56
Trigger:
  • If ((Facing of (Picked unit)) Equal to (Angle from (Position of (Picked unit)) to (Target point of ability being cast))) then do (Do nothing) else do (Curse unit)

Are you looking for something like this?

I think(im not sure) that would be looking directly away from the area actually, you would have to divide that value by 180 so it would be something like this
Set FacingAngle = ((Angle from (Position of (Picked unit)) to (Target point of ability being cast))) / 180)
If ((Facing of (Picked unit)) Equal to FacingAngle

then you would add that unit to a unit group and yadda yadda all that stuff
Also if im wrong and Kaerf is right i apologize :)
 

HydraRancher

Truth begins in lies
Reaction score
197
I think what he means is that if a unit's vision looks directly through the circle, meaning through one end of the circumference and out the other; then it will get hurt. And that is hard to code.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
first you get the angle between the picked units position and the target point of the ability.
then you add some value to this degree and do "mod 360" and then you subtract the same value and do the "mod 360" again.
now you can check whether the facing angle of the unit is in between those 2 values.
why? because the chance that the facing of the unit is exactly the angle towards that point is so small it wont happen even once in a game.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
You can solve this with a little geometry and trigonometry.
Trigger:
  • (Sin((Abs(((Facing of Unit) - (Angle from UnitPos to CircleCenter)))))) Less than (Radius / (Distance between UnitPos and CircleCenter))


It'll even detect if it's within the circle, since Sine does not go above 1, and if the distance is less than the radius, it will be larger than 1.

I think I did it right... Go go, illustration!
2uiubvd.gif
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top