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

[Spell] Units moving in a circle

Status
Not open for further replies.
Pseudocode:

Code:
function MoveUnitAroundCaster(unit circler, unit circlee)
    int i = 0
    while i >= 0
        circler.SetX(circlee.getX() + 250*Cos(i*1/50*PI))
        circler.SetY(circlee.getY() + 250*Sin(i*1/50*PI))
        if i += 1 < 2147483647
            i++
        wait(1/50)

The principle is that we have a certain interval such as 0.04 or 0.03, (I used 0.02 or 1/50.), and that we move the circler around the circlee via SetUnitX and SetUnitY, basing the coordinates off of the circlee's coordinates. We allow the passage of that time interval to execute the moving all over again.

Do note that for all intents and purposes, a timer should be used for periodic intervals of such shortness instead of a Wait - real someDur seconds GUI function because of desynchronization.
 
A Simple Version supporting 1 Rotating Unit showing the concept in GUI.

  • Simple Rotate for 1 Unit
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set CurrentAngle = (CurrentAngle + (RotationSpeed x 0.05))
      • Set Loc = (Position of Center)
      • Set Loc2 = (Loc offset by CurrentDistance towards CurrentAngle degrees)
      • Custom script: call RemoveLocation(udg_Loc)
      • Unit - Move RotatingUnit instantly to Loc2
      • Custom script: call RemoveLocation(udg_Loc2)
To support more then 1 Unit you need some kind of indexing or use an hashtable.

Another way would be to use Spell System which takes away the burden to calc index and the intervale.
 
Level 5
Joined
Oct 16, 2015
Messages
132
Ok, I've tries it but there is a problem. It rotates in a circle form, but there is like an error that it overlaps on the center and moves instantly to the opposite of the point it must be and I don't know why. It shows like 2 units rotating around the point.

It is kinds hard to explain because I suck at english, forgive me.
 
Status
Not open for further replies.
Top