Smooth Random Movement (With in Constraints of Box) Error with if statement

I’m assuming my error is simple but I can’t figure it out. I’ve tried adding {} at the end of the statement but its not a fix

any help is appreciated learning curve is steep lol

Add a colon : at the end of your line 59
Add a tabulation for your line 60.

it worked but cause issues further up…Dangling"=" Do you happen to know where I could learn how to move an object randomly with smooth movement?Ex: A Sphere moving in a box randomly. I’m assuming I’d use the MoveTo function OverTime using my constraints but I can’t figure it out on my own as I’m very new

Use the PropMover device to make smooth movements.
You can reference it to your script as so:

@editable
PropMover: prop_mover_device = prop_mover_device{}

Then you can follow the documentation about the Events and Class members : Prop Mover Device. Calling Begin() will make it move.

What is overtime: Prop.GetTransform()? Idk, maybe I’m missing on something, but you need a float value after rotation. (MoveTo(Position:vector3, Rotation:rotation, OverTime:float)).

Also, MoveTo doesn’t have the decides effect, which means you don’t need to put it inside an if statement.

Last thing, you need a Sleep() statement if you’re using a loop, otherwise it will give you an error.

This is an example code:

MoveNextTarget()<suspends>:void=
    loop:
        RandX:=GetRandomFloat(MinimumPosition.X, MaximumPosition.X)
        RandY:=GetRandomFloat(MinimumPosition.Y, MaximumPosition.Y)
        RandZ:=GetRandomFloat(MinimumPosition.Z, MaximumPosition.Z)
        NewPosition:=vector3{X:=RandX, Y:=RandY, Z:=RandZ}
        NewRotation:=MakeRotationFromYawPitchRollDegrees(0.0, 0.0, 0.0) #Default rotation since you didn't have it

        Prop.MoveTo(NewPosition, NewRotation, 1.0)#It will move to new position, with a default rotation, in 1 second
        Sleep(1.0) #Time to wait before loop starts again
1 Like

The example helped a ton! Also thank you for explaining how to use MoveTo function

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.