Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

TweenService - Part through object?

Asked by 7 years ago
Edited 7 years ago

Okay, so the basic idea of what I'm trying to do is when the player press's the letter Z, 5 cannon balls under the BasePlate will go upwards to a certain position. Everything works fine until the cannon balls attempt to go through the basePlate and fail, causing TweenService to glitch and the part teleport above to the final position (Since the time of the tween is a second)

I found out that putting the cannon balls under nothing works, however, I'm trying to make an impression of the blocks coming through the ground. The only way that I can find for this to work is turning the BasePlate's can collide property to false, however that won't allow the player to move. Is there a collision property on certain objects or a way to do this? One of the scripts are:

local tweenService = game:GetService("TweenService")

local Part = script.Parent.Parent.CannonBall5

local tweeningInformation = TweenInfo.new(
    1, 
    Enum.EasingStyle.Quad, 
    Enum.EasingDirection.Out, 
    0,
    false,
    0
)

local partProperties = {
Position = Vector3.new(Part.Position.X, Part.Position.Y + 10,Part.Position.Z);
}

local Tween = tweenService:Create(Part,tweeningInformation,partProperties)
Tween:Play()

EDIT: CanCollide false baseplate doesn't work either

0
PhysicsService didn't work either. superhudhayfa 39 — 7y
0
Use CFrame, don't set the Position itself. Mayk728 855 — 7y
0
CFrame doesn't have a "smooth effect" superhudhayfa 39 — 7y
View all comments (4 more)
0
Use collision groups. iRexBot 147 — 7y
0
Tried that and didn't work. superhudhayfa 39 — 7y
0
CFrame is the only reliable option. Setting the position doesn't allow for it to go through other parts. CFrame can be smooth if the position isn't set at a large number. Mayk728 855 — 7y
0
Mmk, I guess. I'll keep trying to find a way with tween service tomorrow. Thanks anyway superhudhayfa 39 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Tweening the part's CFrame instead of it's Position solves this issue. So instead of:

local partProperties = { Position = Vector3.new(Part.Position.X, Part.Position.Y + 10,Part.Position.Z); }

You would do:

local partProperties = { CFrame = CFrame.new(Part.Position.X, Part.Position.Y + 10, Part.Position.Z) }

The end result is identical, except the tweening part won't avoid colliding with objects in it's way.

0
Thanks for the answer, however it didn't work. I tested it by changing the ground to 0.5 transparency, however, when tweening the cframe, it caused a lag spike for a moment and puts the part into's final position. superhudhayfa 39 — 7y
0
That's weird. It's working in my test with no lag or teleporting. I'm not sure what the difference would be. Even with collision on the part smoothly tweens through other parts. Are you modifying the cannonballs in any other way other than the tween? vector3_zero 1056 — 7y
Ad

Answer this question