![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Clicksurfer |
Hi there,
After completing the Dodge The Creep tutorial, I figured I’d liven things up by making the spawned mobs rotate over time (so instead of going in a straight line, they’ll make a circular motion).
However, I am unsure what value I need to supply and where in order to make this happen.
The mobs are given their initial velocity using the following logic:
# Set the mob's direction perpendicular to the path direction.
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
# Set the mob's position to a random location.
mob.position = $MobPath/MobSpawnLocation.position
# Add some randomness to the direction.
direction += rand_range(-PI / 4, PI / 4)
mob.rotation = direction
# Set the velocity (speed & direction).
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
mob.linear_velocity = mob.linear_velocity.rotated(direction)
I thought all I would need to do would be add some angular velocity to get the object to spin:
mob.angular_velocity = PI
But this only got a weird effect where the object visually rotates but it is still heading in more or less the same direction.
Any ideas? Thanks in advance!