• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Mathmatics Genius Help II

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
Ok now i need a formula for getting a number for something that is simmilar to a knockback,

Ok lets say you target a point, then you get the location and the distance between those two points. I need a unit to travel that location for over lets say over 2 secconds, but when it moves it starts fast and ends slow, it will loose ("example -0.03" but that dont need to be 0.03) every 0.01 secconds or so, maybe 0.02 or sum ( does not matter :>).

So if anyone have an idea, just post'em.

Thx :D
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Δx is the displacement (distance for all you care).

vi is the initial velocity (how fast you should be moving at the start of the knockback).

vf is the final velocity (how fast you should be moving at the end of the knockback).

a is the acceleration (should be negative since you're slowing down).

t is the time it will take to go that displacement.
 

Vex

Vex

Level 3
Joined
Dec 1, 2007
Messages
33
Haven't tried myself and don't have enough patience to try out and explain in detail,
but you could create a function that initiates a loop. Inside the loop you do 3 things,

1. Calculate a number, 2. Move the unit (that is being knocked back) and 3. Wait before looping again.

The calculated number, you get from the formula posted above. This is the distance the unit should move every time the loop runs.
When you move the unit, you know from, to and it's current position. Just move it in the proper direction using distance=the number previously calculated.
The waiting should perhaps be done using a countdown timer to get a more smooth animation, haven't tried either so not sure.

Good luck!
 
Level 6
Joined
Mar 15, 2005
Messages
112
Start Effects
Events
Unit - A unit owned by Player 1 (Red) Starts the effect of an ability
Conditions
(Ability being cast) Equal to (==) Bash
Actions
Set Target = (Target unit of ability being cast)
Set FacingAngle = (Facing of (Casting unit))
If (Rate Less than (<) 10) then do (Set Rate = 10) else do (Do nothing)
Trigger - Turn on Run Effects <gen>


The next trigger must be run by the first and initially turned off:

Run Effects
Events
Time - Every 0.01 seconds of game time
Conditions
Rate Greater than (>) 5
Actions
Set Position = (Position of Target)
Unit - Move Target instantly to ((Position offset by (0.00, 0.00)) offset by (Real(Rate)) towards FacingAngle degrees)
Set Rate = (Integer(((Real(Rate)) - 0.05)))
Point - Remove Position

I haven't tested so let me know if it works. Also I added anti leak. Change rates etc to adjust. +rep would be appreciated if this works =D
 
Status
Not open for further replies.
Top