HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unit Facing Help

05-31-2006, 02:28 PM#1
James59281
Hi all!
I'm having a bit of trouble with a custom ability. I have an ability based on shockwave, with basically all fields blank.
When a unit casts the ability i create a custom unit that then is faced towards the target point at which the ability was cast.
A periodic event is used to move the custom unit in the facing direction.

This is pretty basic, i'm sure you'll appreciate. My question is this- when i click to cast the ability, the custom unit does not seem to go directly to where i clicked, but instead at an angle to this, just a few degrees out.

so if i clicked here ---> X
it might end up here--------> X




with me standing:
here--> X

What causes this, and can i correct it?
05-31-2006, 03:16 PM#2
blu_da_noob
Depending at which angle the custom unit is created, it may take a little while to turn to the correct angle. Why not just create the unit facing that direction?
05-31-2006, 03:33 PM#3
James59281
Quote:
Originally Posted by blu_da_noob
Depending at which angle the custom unit is created, it may take a little while to turn to the correct angle. Why not just create the unit facing that direction?

Perhaps i wasn't too clear in my post. The unit actually is created and turned to the angle when it's created. Still haven't resolved the problem.
05-31-2006, 03:53 PM#4
blu_da_noob
Please post your triggers (in trigger tags). Your description is ambiguous.
05-31-2006, 04:04 PM#5
James59281
Here's my first trigger
Trigger:
Unit - A unit Begins casting an ability
(Ability being cast) Equal to Shoot

Set CastingUnit = (Casting unit)
Wait 0.50 game-time seconds

Unit - Create 1 Bullet for Player 1 (Red) at (Position of CastingUnit) facing (Facing of CastingUnit) degrees

Then the one to move it is:

Trigger:
Time - Every 0.01 seconds of game time

Collapse Unit Group - Pick every unit in (Units in (Entire map) matching (((Unit-type of (Matching unit)) Equal to Bullet and do (Actions)
Loop - Actions
Collapse
Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 8.00 towards (Facing of (Picked unit)) degrees)
Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + 8.00)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Mana of (Picked unit)) Greater than or equal to 2000.00
Collapse Then - Actions
Unit - Kill (Picked unit)
Else - Actions
Else - Actions

Unit Group - Pick every unit in (Units in (Entire map) matching (((Unit-type of (Matching unit)) Equal to Bullet) and do (Actions)
Collapse Loop - Actions
Set PickedUnit = (Picked unit)
Collapse Unit Group - Pick every unit in (Units within 60.00 of (Position of PickedUnit)) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Mana of PickedUnit) Greater than 60.00
((Picked unit) is dead) Equal to False
(PickedUnit is dead) Equal to False
(Level of 100% Evasion for (Picked unit)) Equal to 0
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Picked unit) has an item of type Active Double-Bladed Lightsaber) Equal to False
((Picked unit) has an item of type Active Lightsaber) Equal to False
Collapse Then - Actions
Unit - Cause PickedUnit to damage (Picked unit), dealing 1000000000.00 damage of attack type Normal and damage type Normal
Else - Actions
05-31-2006, 04:22 PM#6
TaintedReality
Well you wait 0.50 seconds, then have the Bullet facing the same way as the Caster. The Caster will probably have turned by then which might be why it's off. Why do you need that wait anyways? Also, having the event 'Begins casting an ability' allows for abuse, if I was playing I could cast the ability then press stop right afterwards; the ability would fire and I wouldn't lose any mana and the cooldown wouldn't start.
05-31-2006, 05:59 PM#7
Rising_Dusk
Just to let you know...

Getting the angle between the target point of spell being cast and the caster is MUCH MORE ACCURATE than getting the facing angle of the caster.
That is so because if the caster is turned around and you cast the spell behind him, he may only rotate halfway to that point before casting, causing errors in the angle.

Also, I would suggest storing the angle into a variable.
That way you don't have to deal with accidental mishaps where it faces the wrong way or such.
05-31-2006, 06:22 PM#8
blu_da_noob
As I suspected, you aren't creating your unit facing the correct angle. As mentioned, create it facing angle between (Position of casting unit) and (Target point of ability being cast). Your triggers, ofcourse, leak and you are using the incorrect event for the casting.
05-31-2006, 06:38 PM#9
James59281
Thanks for your help, everyone!
I changed it to be the angle between the unit and the casting point so it works fine now!