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

**URL:** <https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466>\
**Category:** Verse\
**Tags:** unreal-engine, unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [July 16, 2023, 7:37am UTC](https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466 "2023-07-16T07:37:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ample](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ample](https://forums.unrealengine.com/u/Ample)\
**Post date:** [July 16, 2023, 7:37am UTC](https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466/1 "2023-07-16T07:37:53Z")

</div>

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

 ![improverformant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/6/e/06ef55ca6877d179b21ef63d85302550b1af2f3d.png)

any help is appreciated learning curve is steep lol

---

<div class="post-metadata">

**Author:** ![Switi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Switi](https://forums.unrealengine.com/u/Switi)\
**Post date:** [July 16, 2023, 8:15am UTC](https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466/2 "2023-07-16T08:15:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ample](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ample](https://forums.unrealengine.com/u/Ample)\
**Post date:** [July 16, 2023, 9:04am UTC](https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466/3 "2023-07-16T09:04:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Switi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Switi](https://forums.unrealengine.com/u/Switi)\
**Post date:** [July 16, 2023, 12:40pm UTC](https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466/4 "2023-07-16T12:40:09Z")

</div>

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

```auto
@editable
PropMover: prop_mover_device = prop_mover_device{}

```

Then you can follow the documentation about the Events and Class members : [Prop Mover Device](https://dev.epicgames.com/documentation/en-us/uefn/verse-api/fortnitedotcom/devices/prop_mover_device). Calling `Begin()` will make it move.

---

<div class="post-metadata">

**Author:** ![itascreations](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@itascreations](https://forums.unrealengine.com/u/itascreations)\
**Post date:** [July 18, 2023, 2:03am UTC](https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466/5 "2023-07-18T02:03:43Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Ample](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ample](https://forums.unrealengine.com/u/Ample)\
**Post date:** [July 18, 2023, 10:23am UTC](https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466/6 "2023-07-18T10:23:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [August 17, 2023, 10:23am UTC](https://forums.unrealengine.com/t/smooth-random-movement-with-in-constraints-of-box-error-with-if-statement/1230466/7 "2023-08-17T10:23:48Z")

</div>

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