[HELP] Trying to Tween with collisions

I’m essentially moving models by tweening.
However, I’m also trying to allow the models to be able to collide with objects in the world.

Right now I’m using;
local GoalMove = {Position = Vector3.new(Target.p.x, Body.Position.y, Target.p.z)}

But the models will go right through everything in its path.

EDIT: Here’s the place if you need a visual representation. Just click on one of the boats, then click any water terrain.

2 Likes

One thing you could try is using BodyMovers to move the ship instead of changing the actual Vector3.

To do this, you would add a BodyPosition to the model, and then in your tweenscript, tween the BodyPosition and the BodyPositions Position.

I did this in one of my projects, and it solved the problem.

I was originally using BodyMovers, but not utilizing tweens, I’ll give it another try.

Anyone else have a way to accomplish this without BodyMovers?

Tweens do not take any physics or obstacles into account and will just increment the CFrame until it reaches the target.

You could try using raycasting to figure out if a move is possible, by checking if there are any objects in a boat’s path and then either blocking the move or stopping the boat before it hits the object.

2 Likes

With BodyMovers:
Since you are using water terrain, you can set the boat’s part’s density to be lower than that of water so the boat can float. Make sure to unanchor all the parts and weld them together.

You’re going to want to use BodyGyro to steer the boat, BodyVelocity to propel it, and BodyPosition to keep it upright.

Without BodyMovers:
I recommend LERPing it when moving it forward instead of tweening. Cast a ray ahead of it to see if it can actually move forward. If it can’t because something is in the way, don’t move it.

You can also give it an artificial rocking effect by LERPing its rotation and Y-axis position slightly up and down, as if its bobbing in the water.

1 Like

If you want collisions then you should avoid TweenService unless you’re, for example, tweening a property that influences a BodyMover rather than its literal goal. Collisions are part of the physics pipeline, tweens are not - they smoothly modify a property across many intermediate frames, with easing information helping determine how the goal is reached (but still anchored on that path).

2 Likes