How do you move a humanoidrootpart along with an animation?

What I’m trying to do is to have an animation, i.e a jump slash, move the humanoidrootpart along with it.

For instance, if i wanted a flash slash attack of sorts, (Like a very quick dash whilst slashing a sword, bordering on teleporting), I’d like to be able to move the humanoidrootpart along with it so that once the animation is over the humanoidrootpart is now in that new position. Additionally, I’d like the camera to keep up with the character during this animation (It is normally centered on the humanoidrootpart, which is static). Oh and it also needs to not move disproportionately. What I mean by this is is that since the humanoidrootpart is the center of the character and it generally stays static during an animation, if a character moves far away from the humanoidrootpart, the slightest rotation on the humanoidrootpart can translate to a change of several studs with the character.

So, to do all of these, I thought about adding another center part to the rig, like the humanoidrootpart, one that would move along during an animation to where the character should be placed. Along with this, I’ve tried adding an alignoriention and alignposition bound to an attachment in both this central part and in the humanoidrootpart. Result is simple: humanoidrootpart did not move along with the part.

Here is a basic example of what I’m trying to achieve using above example (flash slash). Cube is where the humanoidrootpart should be in 3d space during the animation.
https://gyazo.com/92b92e4d197d7375d288deb6fb16ee6c

Now I know I can just tween the humanoidrootpart’s position, but I’d like the player to be able to turn mid-animation and also tweening everything individually may be extremely tedious with more complex attacks.

If anything’s unclear, let me know, I’ll try to clarify it asap.

3 Likes

I know your exact problem as I have had to deal with it before.
Unfortunately, there isn’t any exceptionally good way of dealing with this problem.
My best suggestion would be to make the animation not move, just do the poses,
and instead have a BodyVelocity (LinearVelocity once that comes out) controlling the movement of the character.
This gives you more control over how the character moves,
like how quickly it goes and the direction you want it to go,
but makes it harder to make good looking animations.

Now the second solution is slightly hackier and probably doesn’t work as well as the first one,
but right before the animation ends you save the torso’s position and when it does end, you
set the HumanoidRootPart’s position to the torso position. I don’t recommend doing this
as it can cause some issues (?).

Also don’t move the HumanoidRootPart with the animation, it won’t fix the problem. The animation is relative to HumanoidRootPart, which if you move the HumanoidRootPart, so does the animation.

5 Likes

What if I were to animate the cube moving separately from the humanoid? I.e using a separate animationcontroller purely for the cube?

Also, the issue I’m facing with my current method is moreso due to the humanoidrootpart not reacting to alignposition and alignorientation

Edit: Couldn’t I just weld the cube to the humanoidrootpart and animate it separately using the animationcontroller?

I think I didn’t read the post properly originally,
however if you were to have a separate AnimationController for the cube,
I think it could work.
You could also weld the HumanoidRootPart to the cube, yes.

Alright, well I tried using the welding method with an separate animationcontroller for the cube, this is the result.

The cube (along with it’s group and HRP equivalent) just disappears after roughly 2 seconds. Even if I don’t play any animations, it still just vanishes. I tried checking both part’s position to see if one was falling into the void, not the case.
I have no idea what’s causing this.
Furthermore, the humanoidrootpart isn’t being moved regardless, even if I make the animation play straight away.

1 Like

The HumanoidRootPart isn’t intended to be moved in an animation, only the limbs of the character are. If you want to move the character to a new position, during an animation, you will need to apply body forces or set the CFrame of the root forward into a certain position.

This is the same way Roblox implements the jump animation. When you perform a jump, the animation is ran in an idle position where the character performs the jump motion but they don’t actually move in the animation. The player movement is actually done by an intern upwards force whereas the animation is just meant to visualise that the Humanoid is in the process of applying the initial upward force.

4 Likes

Weld was being done locally, so it was in fact falling on my screen. Now it no longer falls. Problem persists, however; weld still does not move the character. WIll try a few more things.

Edit: @colbert2677 please re-read thread thoroughly. I am not trying to move the humanoidrootpart with an animation, but along with an animation (a third party object the humanoidrootpart is welded to, for instance)

Sorry, your thread isn’t quite clear on the first read through. There’s also a lot of text which makes sifting through your intended implementation more difficult.

I don’t think that very much changes about my response even then, it’s just that bits of the post don’t fit the bill correctly and with a little bit of change in interpretation of the post, it probably should make sense towards your case. I think?

AlignPosition should be working for you here and I do know that systems have been accomplished using it (e.g. custom character controller uses it to keep players to inverted surfaces). Interesting that it hasn’t worked out for you. I’ll try testing around with that later and let you know if I get anything conclusive unless you find a solution before then.

Hold on, let me provide you with a rblx file for this.

Edit:The cube rig itself is located in startercharacterscripts.

The xSIXxAnimationSaves folder inside of the dummy contains a single animation, but depending on whether or not you put it in the companion model or in the dummy, it gives you the corresponding animation. (slash and cube moving). Use those to upload the animations.AnimationTest.rbxl (24.1 KB)

1 Like

What would be your final goal after you figure this out?
Like what are you planning to do?
I’m slightly unclear what your use-case is, and it’d help out me and maybe others to know.

I’ve provided an use case example in original post. Any attack or action that requires movement, basically. Like using a jump slash to reach a higher ledge or ducking a few studs to the left before coming back and striking a player (Which would be exploitable for greater mobility during fights if a player were to turn 180 mid duck, making the game more skill based). I don’t want to use velocity or bodymovers because they don’t allow for finer movements and would generally be much more time consuming than simply being able to draw the path of a player via animations.

It seems that you could use body forces to achieve these actions.
Is there anything that prevents you from using body forces?

Sorry if you’ve previously answered this, it’s just slightly unclear for me.

It does not allow for finer movements. What I’m trying to achieve is something like this

where the movement is really smooth and (I am fairly certain) that it is using animations to move the humanoidrootpart.

If you’ve played breath of the wild, think of link’s spin attack, except going around in a spiral. Bodymovers would most likely not allow for this, not without overcomplicating the code a tad.

Ooh, yes, DahNoob’s work. Lovely stuff.

IIRC he doesn’t use animation objects at all and his work isn’t FE compatible, they’re created through lerping on the client. If you’re familiar with old script builder script powers, all the animations were done using hard coded CFrame cycles.

I know he uses MAS occasionally (he’s also in the Discord) but I’ve never found any published animations and I believe that was only a one-time thing where he mentioned trying out animations for a certain tool in an old Twitter post.

That can be achieved by using body movers.

The way you’d be doing this with body movers would be to have an animation that doesn’t actually move around. Then you get the CFrame from HumanoidRootPart, the LookVector from the CFrame (based on a sword lunge), and you create a BodyVelocity (LinearVelocity once that comes out). Now the BodyVelocity’s velocity should be set to the LookVector * Speed_of_the_lunge. You should also remember to set the MaxForce to something like Vector3.new(1, 1, 1) * math.huge, so that it actually allows the BodyVelocity to move.

Edit: Also if there’s a limitation/problem with using body movers, please do tell me as it would be really useful as I work with body movers a lot.

Edit 2: The animations seem to be near instant when it starts and stops, this can be achieved by playing around with the first parameter of AnimationTrack:Play and AnimationTrack:Stop. For more information, here’s a developer hub article.

MAS? Also if it isn’t FE compatible, I’d still like to achieve something as close to it in terms of smoothness as possible with FE enabled.

Edit: @guidable LinearVelocity isn’t a body mover. Someone linked it earlier but it lead to a default article. I think you’re thinking of bodyvelocity?

Moon Animation Suite.

You can make it FE compatible by having each client animate characters on their own end. The client would just need to use the server as a medium to tell other clients to perform a certain animation cycle. This would be necessary since lerps don’t replicate.

I don’t know the specific implementation details at all, so sorry I won’t be able to help you in that capacity.

Oh. I just wasn’t familiar with the acronym. It’s what I used to animate the example. Lerping each frame is kind of irrelevant in my use case, however. Nothing’s stopping me from just loading it as an animation. I’m more so interested in making the player move along.

I have somewhat of experience with the implementation of such a system, just with welds.
It’s pretty easy to make such a system, but I don’t really recommend doing such as it is easily exploitable,
and often times it’s just much easier to do it using animations.
When I started using animations instead of this so said weld system,
I found it much easier to do with the animations.

I’ll create a small prototype for lunging using animations + body movers this upcoming week
and I’ll share it.

I’ve tried setting velocity directly, lead to the player being able to go way too far if they’re not grounded. Tried tweening a bodyvelocity’s maxforce down, causes the player to float for a bit during the animation (which I want to avoid). Trying weld didn’t work, alignments didn’t work, etc. Kind of at a loss for what to do.