I Need Help for Playing Animations
-
Hello everyone. I'm new to modding. I'm working on a smoking mod for learn how to code. I'm using this for play smoking animation on just upper body:
Game.Player.Character.Task.PlayAnimation("amb@world_human_smoking@male@male_a@idle_a", "idle_c", 8.0f, -8.0f, -1, (AnimationFlags)49, 0.0f);
But there is a problem. The animation plays without the cigarette. I need to know how to give a cigarette to player's hand. Thank you.
-
@ekmuz You need to spawn the prop (cigarette) and then attach it.
something like this
MyCig = World.CreateProp("Put name of cig prop here", YourPed.GetOffsetInWorldCoords(new Vector3(0, 3, 0)), true, true); MyCig.AttachTo(YourPed, 60, new Vector3(0, 0, 0), new Vector3(0, 0, 0));
-
@JohnFromGWN or use a scenario for smoking
-
@JohnFromGWN Thank you so much. I will try the first solution.
But when i use a scenario, i can't control player while animation is playing. The player can't walk when I use a scenario. I want to make player controllable when smoking.
-
@JohnFromGWN Hello again. I will be very happy if you can help me. I tried your first solution and it worked well. But i can't rotate the cigarette.
Here is my code:cigarette = World.CreateProp("ng_proc_cigarette01a", Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0, 3, 0)), true, true); cigarette.AttachTo(Game.Player.Character, Game.Player.Character.GetBoneIndex(Bone.SKEL_R_Finger22), new Vector3(0, 0, 0), new Vector3(0, 0, 0));
When I try to change the rotation of the prop, it does not work. What can I do for fix this? I know, the second "Vector3" of .AttachTo command is rotation, but nothing happens when I change that. Please help me. Thank you again.
-
It works perfectly for me, just play with the values, some are sensitive, others are not
cigarette.AttachTo(Game.Player.Character, 60, new Vector3(CigValXFloat, CigValYFloat, CigHeightFloat), new Vector3(CigValPFloat, CigValRFloat, CigValYawFloat));
or try this mod which apparently will allow you to export the coordinates:
-
@JohnFromGWN Forgive me for my ignorance but what is the things that named like "CigValXFloat"? I'm so new at SHV.NET.
And I'll try the mod that you linked in your reply.
-
@ekmuz I'm just creating variable names for all 6 vector parameters rather than hard coding them.