Whenever I try to tween a character rig’s rootpart position and orientation, it only moves the rootpart and not all the other body parts. The way to fix this was using CFrame instead of Position, but how can I tween the CFrame’s position and orientation separately because I want to tween them at different speeds, while also moving the other body parts with it?
I believe that welds only update when you tween the CFrame. I recently saw a post with more detail on how to only move the position/orientation and still get the welds to update, but I’ll need a couple minutes to find it…
Found it!
I hope that helps!
This post talks about how to modify the position without modifying the orientation though, I want to modify both but in separate tweens.
Ah, my mistake. If I’m understanding correctly, try this:
In tween A, use CFrame.new(target.Position) * CFrame.Angles(part.Rotation.X, part.Rotation.Y, part.Rotation.Z)
to tween the position.
In tween B, use CFrame = CFrame.new(part.Position) * CFrame.Angles(target.Rotation.X, target.Rotation.Y, target.Rotation.Z)
to tween the rotation.
This makes the rig float around and rotate weirdly and diagonally
Well, CFrames
are Basically both your Position, and your Rotation, so In order to update to Update one of them and the other one seperately, you would probably have to update both of them at the same time, as only Applying the Position part of the CFrame
will reset the Rotation back to 0,0,0, and only Applying the Rotation Part of the CFrame
will reset the Position back to 0,0,0.
But I am trying to update them separately in two different tweens, is that not possible?
Not Really, So Basically you are telling the Tween to Interpolate towards a specifc point, When The Second Tween is Created, It basically Overrides the First Tween, and the Second Tween will we Played, so like this, Lets say you have a Point in a Position you want to Lerp towards:
pointA = Vector3.zero
pointB = Vector3.new(10, 10, 10)
When you tell the Object to Move towards this point using Tweens, It will try to go there, but Because you give it a new Value to Move Towards, it will move to the new Value instead of the Old one (It depends if you change the Exact same Property).
With Normal BaseParts
, they have separate Properties that allow you to move the Position and Rotation Separately, called Position
, and Orientation
, you can Apply both of them, at different Times, and it will be ok, but with Models
, you dont have these Properties, unless you are trying to Move the PrimaryPart of the Model, But the Issue with this on Characters is that when you change these Properties it can offset the RootPart of the character, which isnt what you want. With CFrames
, THat doesnt really happen, and with CFrame
you can Apply both the Properties that the same time, and as explained earlier:
So there is no way to tween positions and orientations separately on a character rig?
It’s possible. You need to change the HumanoidRootPart
properties.
When you tween the rootpart’s position, the rest of the character doesn’t move with it.
Is the rig anchored? That might be it.
Yes but I have to have it anchored since cancollide is off for each body part, so the player can’t touch with the model. Probably should’ve mentioned this before, but this game is in the tower defense genre, and the character rigs that I’m trying to tween are the enemies, and I can’t have the player be able to collide with them.
With TweenService
is not, If he is going to be using CFrames
then he would need to update both Position and Rotation, The Issue with using the HumanoidRootPart (If using Position
and Orientation
) is that it would offset from the Center of the Player.
Make sure you read the everything I said, because you missed a couple of things.
Interesting. I tried something like that a few years ago though, and it worked fine. Maybe Orientation
is the same as Rotation
now?
I guess the only way possible is to tween two CFrame values and then combine them together when tweening the whole model using PivotTo
.
Funny you mention it, I’ve also been working on a tower defense game. If you want to be more specific about your problem (What exactly are you trying to get the enemies to do?) then perhaps I can help more.
Anyway, consider using collision groups to prevent the player and enemies from colliding with each other.
Turn CanCollide back on for the rig, then add it to a Collision Group called, let’s just say, GroupA (Name it whatever you want though).
Add every part of the player to GroupB. Make sure GroupA and GroupB can collide with Default (The Collision Group everything in the game is set to by default), but not with each other.
To set the player’s collision group, make sure you create a collision group called “Players” (or whatever else you want, just make sure you change the name in the below script as well), then just put the below script in ServerScriptService.
local Players = game:GetService("Players")
-- Fires when a player is added to the game
Players.PlayerAdded:Connect(function(player)
-- Fires when player's character loads
player.CharacterAdded:Connect(function(character)
-- Keep this wait here just so the character can fully load in.
-- Reduce it a little more if you want, but I wouldn't set it below 0.25
task.wait(1)
-- Loops through everything in the player
for _, part in ipairs(character:GetDescendants()) do
-- Checks if part is a Part or MeshPart, as these are the parts whose collision group will need to be changed
if part.ClassName == "Part" or part.ClassName == "MeshPart" then
-- Sets collision group
part.CollisionGroup = "Players"
end
end
end)
end)