Set movement/walking animations?
-
Hello, does anyone know how to set movement / walking animations?
-
@LeeC2202 @stillhere @aimless @Frazzlee
-
@NotCrunchyTaco
Function.Call(Hash.REQUEST_ANIM_SET, "move_m@gangster@var_e");
while (!Function.Call<bool>(Hash.HAS_ANIM_SET_LOADED, "move_m@gangster@var_e"))
{
Wait(100);
}
Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@gangster@var_e", 1048576000);And to reset.
Function.Call(Hash.RESET_PED_MOVEMENT_CLIPSET, Game.Player.Character, 0.0f);
-
@aimless Thank you for your help as always!
Hopefully this works
-
@aimless said in Set movement/walking animations?:
Function.Call(Hash.REQUEST_ANIM_SET, "move_m@gangster@var_e");
while (!Function.Call<bool>(Hash.HAS_ANIM_SET_LOADED, "move_m@gangster@var_e"))
{
Wait(100);
}
Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@gangster@var_e", 1048576000);How would I set this as the movement clipset?
anim@sports@ballgame@handball@ ball_sprint
-
@NotCrunchyTaco I think you have to use the ones with move in them.
-
@aimless It kind of does. Other than this animation I don't know how I will get dribbling for BasketballV?
-
@NotCrunchyTaco Have you ever looked into the IK (Inverse Kinematics) functions on a Ped? There's a native called SET_PED_CAN_ARM_IK.
I have never actually tried but I always wondered if that would let you override the arm position by moving the hand bones. If that was the case, you could probably use normal walk/run animations and use IK to match the hand to the ball.
The way IK usually works, is you move the end of the bone chain and the model moves to maintain set limits with all the bones attached to it. Each IK node has a weight and that controls how much a node can be pulled by the IK chain. You see it in use when you walk over different height terrain and the foot changes position based on the height of the ground beneath it.
-
@LeeC2202 Good suggestion! I am famaliar with IK's and IK chains when I used to do 3D Renders with Cinema 4D. I could try to mess around with those somehow.....
-
@NotCrunchyTaco Why don't you just loop the animation on the upper body? You can actually have animations play while the player is walking. Here's an example use your anim:
PlayerPed.Task.PlayAnimation("anim@sports@ballgame@handball@", "ball_idle", 8.0f, -8.0f, -1, (AnimationFlags) 49, 0.0f);
(AnimationFlags)49
is telling the script "We want to play this on the upper body, and loop the animation infinitely."Here's more info on animation flags, ripped straight from the NativeDB
Odd number : loop infinitely Even number : Freeze at last frame Multiple of 4: Freeze at last frame but controllable 01 to 15 > Full body 10 to 31 > Upper body 32 to 47 > Full body > Controllable 48 to 63 > Upper body > Controllable
Controllable means that you can play the animation and it will blend with the players movement. Usually the animation will discontinue play after moving to much but using 49 tells the game you want the anim to loop no matter what (since it's an odd number, and it's within the controllable range).
Hope this helps, bud. It's what I'm using for the Spider-Man mod.
-
@NotCrunchyTaco Also for ball movement you can try what I used for my batman bats script that allows you to bounce a coordinate up and down (in your case it would be on the Z axis):
-- Put this in a utility file or some static class --
public static float PingPong(float t, float length) { t = Repeat(t, length * 2f); return length - Math.Abs(t - length); } public static float Repeat(float t, float length) { return t - Floor(t / length) * length; } public static float Floor(float f) { return (float)Math.Floor(f); }
-- And use this to bounce the ball --
var position = ball.Position; position.Z = Utils.PingPong(Game.GameTime / 100, bounceSpeed) + Game.Player.Character.Position.Z - someOffset; ball.Position = Vector3.Lerp(ball.Position, position, Game.LastFrameTime * smoothSpeed);
-
@sollaholla Thanks man. I was thinking using the upper body only tag. Thank you for the code and the examples
-
@aimless Can you be specific where in-game is it the menyoo do i type this or place it somewhere in the game mods files??i'm very confused where exactly i should type this out and place it?