• 🏆 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!

[Solved] Dash and collision spell

Status
Not open for further replies.
Level 9
Joined
Sep 20, 2015
Messages
385
Hello, im trying to make a spell that make the caster dash in a direction, if the caster collide with a unit in front of him during the dash, the caster stops and kick the unit back damaging it, otherwise just move to that point.
I've already made a dash ability, based on channel, with 2 triggers, 1 for casting, 1 loop for moving the unit. It works fine.
The problem is detecting when the caster collide with a unit that is in front of him.
For the collision i use the event : 'unit comes within 100 of caster' but it is circular, so if the caster dashes and pass near a unit it stops anyway.
I tried messing up with conditions and angles but didn't manage to make it work. I have also searched for some similar treads but most of them are related to an ability cast event not to a collision detecting event. Also i saw a lot of possibilites and need to choose the best one.

P.S. another question, i keep getting script error after i added a custom script to a gui trigger, i'll post the complete trigger later.

Thanks in advance
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
The math for "creating a cone" in front of the caster is nasty if you don't understand trigonometry. I've made a spell like this a ton of times, so I'll link you the spells I made that utilize the math.
What you need is this bit:
JASS:
set arcLength = the field of view
set angle = Cos(the angle from the unit to the object)
if (angle >= arcLength) then
    // object is within the cone
else
    // object is not within the cone
endif
 
Status
Not open for further replies.
Top