Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

[Tutorial] Creating synchronized animations (GTALua)


skyrayfox
 Share

Recommended Posts

[Tutorial] Creating synchronized animations (GTALua)

 

I couldn't find any any posts about this on the forums so I managed to figure it out myself. I wanted to sync two ped animations together, so here it is in GTALua code!:

streaming.RequestAnimDict("[email protected][email protected]")scene1 = natives.PED.CREATE_SYNCHRONIZED_SCENE(playerPosition.x,playerPosition.y,playerPosition.z-1, 0.0, 0.0, 180.0, 2)natives.PED.SET_SYNCHRONIZED_SCENE_LOOPED(scene1, false)natives.AI.TASK_SYNCHRONIZED_SCENE(targetPed, scene1, "[email protected][email protected]", "flee_backward_shopkeeper", 1000.0, -4.0, 64, 0, 0x447a0000, 0)natives.AI.TASK_SYNCHRONIZED_SCENE(playerPed, scene1, "[email protected][email protected]", "flee_backward_thief", 1000.0, -4.0, 1, 0, 0x447a0000, 0)natives.PED.SET_SYNCHRONIZED_SCENE_PHASE(scene1, 0.0)

 

How does it work?

 

First we request the animation dictionary. In GTALua we can use the wrapper function that will request and load the animations for us before we can use them. Use STREAMING::REQUEST_ANIM_DICT() native instead if not using GTALua:

streaming.RequestAnimDict("[email protected][email protected]")

Then we need to set up the animation scene. We will center the animation on our player but you can use any coordinates you want. Both Peds will be teleported there once the scene starts.

scene1 = natives.PED.CREATE_SYNCHRONIZED_SCENE(playerPosition.x,playerPosition.y,playerPosition.z-1, 0.0, 0.0, 180.0, 2)

We can choose to loop the animations if we want. Then we can set up the animations for the player and target ped, refer to the animation list for animationDictionaries and animationNames. For this example we will use a mugging animation.

Values after the animation names are currently unknown.

natives.PED.SET_SYNCHRONIZED_SCENE_LOOPED(scene1, false)natives.AI.TASK_SYNCHRONIZED_SCENE(targetPed, scene1, "[email protected][email protected]", "flee_backward_shopkeeper", 1000.0, -4.0, 64, 0, 0x447a0000, 0)natives.AI.TASK_SYNCHRONIZED_SCENE(playerPed, scene1, "[email protected][email protected]", "flee_backward_thief", 1000.0, -4.0, 1, 0, 0x447a0000, 0)

Finally we can start the animations from the beginning (0.0 is the time I assume). You can change the second argument value if you want to start the animations later, from the middle or end etc.

natives.PED.SET_SYNCHRONIZED_SCENE_PHASE(scene1, 0.0)

Of course you may also need to update your GTALua natives used in this example to accept proper values.

Check if TASK_SYNCHRONIZED_SCENE is accepting string values for 3rd and 4th argument in native_call_layout.ini file:

TASK_SYNCHRONIZED_SCENE=aassffaafa)v

.

 

Synchronized animations for Peds and Objects

 

Sync animations also work for peds and objects! Here's a synced animation of Franklin opening the door to his house.

It works the same way except we need to replace the second ped with the "door " object (door model hash is "520341586") and use PLAY_SYNCHRONIZED_ENTITY_ANIM() native instead:

streaming.RequestModel(520341586)object = natives.OBJECT.CREATE_OBJECT(520341586, playerPosition.x,playerPosition.y,playerPosition.z, true, true, false)streaming.RequestAnimDict("[email protected]_home")scene = natives.PED.CREATE_SYNCHRONIZED_SCENE(playerPosition.x,playerPosition.y,playerPosition.z, 0.0, 0.0, 180.0, 2)natives.AI.TASK_SYNCHRONIZED_SCENE(playerPed, scene, "[email protected]_home", "franklin_enters_old_home", 1000.0, -1000.0, 0, 0, 0x447a0000, 0)natives.ENTITY.PLAY_SYNCHRONIZED_ENTITY_ANIM(object, scene, "franklin_enters_old_home_door", "[email protected]_home", 1000.0, -1000.0, 0, 0x447a0000)
Hopefully somebody will find this useful!
Link to comment
Share on other sites

This would be great. Do you know how many synchronized animations are there to use? Otherwise we can look through the Decompiled scripts. Looks like synched scenes share the same anim dict.

 

I am hoping to find a way to allow animations to occur while still in control of your vehicle. I may make a new thread on this.

Link to comment
Share on other sites

This would be great. Do you know how many synchronized animations are there to use? Otherwise we can look through the Decompiled scripts. Looks like synched scenes share the same anim dict.

 

No idea but it should work with all animations, even ones that aren't meant to be synced together.

 

Very nice tutorial!

Do you mind if I add it to the wiki?

 

Go ahead !

Link to comment
Share on other sites

That's awesome!, Do you know how we can change the duration it ends? Of course natives.PED.SET_SYNCHRONIZED_SCENE_PHASE(scene1, 0.0) works for starting later, but what about ending earlier?

Edited by dehan
Link to comment
Share on other sites

That's awesome!, Do you know how we can change the duration it ends? Of course natives.PED.SET_SYNCHRONIZED_SCENE_PHASE(scene1, 0.0) works for starting later, but what about ending earlier?

 

I don't know of any natives for that so I use a GTALua timer that clears ped tasks when I want. For example this one stops the animation after 10 seconds:

timer.Simple(10000, function()    natives.AI.CLEAR_PED_TASKS_IMMEDIATELY(playerPed)end, "")
Link to comment
Share on other sites

Edit:

 

You may be able to use ENTITY::STOP_SYNCHRONIZED_ENTITY_ANIM

(C++)

 

--

 

 

That's awesome!, Do you know how we can change the duration it ends? Of course natives.PED.SET_SYNCHRONIZED_SCENE_PHASE(scene1, 0.0) works for starting later, but what about ending earlier?


I don't know of any natives for that so I use a GTALua timer that clears ped tasks when I want. For example this one stops the animation after 10 seconds:
timer.Simple(10000, function()    natives.AI.CLEAR_PED_TASKS_IMMEDIATELY(playerPed)end, "")

Yeah, ended up doing that haha. Cheers

Edited by dehan
Link to comment
Share on other sites

MrGTAmodsgerman

 

[Tutorial] Creating synchronized animations (GTALua)

Thank you for this tutorial.

1.But what is about set a animation on the actual character like Franklin...?

2.And how to stop a animation?

3.How can i view a animation to know what what is?

 

Thank you in the future.

Link to comment
Share on other sites

 

 

[Tutorial] Creating synchronized animations (GTALua)

Thank you for this tutorial.

1.But what is about set a animation on the actual character like Franklin...?

2.And how to stop a animation?

3.How can i view a animation to know what what is?

 

Thank you in the future.

 

 

 

See:

1)

GTALua code

   if IsKeyDown(KEY_F10) then            natives.STREAMING.REQUEST_ANIM_DICT("[email protected][email protected]@[email protected][email protected]");                                     if natives.STREAMING.HAS_ANIM_DICT_LOADED("[email protected][email protected]@[email protected][email protected]") then                                        print("loaded"); //GTALua console                natives.AI.TASK_PLAY_ANIM(natives.PLAYER.PLAYER_PED_ID(), "[email protected][email protected]@[email protected][email protected]", "getup_l_0", 8.0, -8.0, -1, 10, 0, false, false, false);                    natives.STREAMING.REMOVE_ANIM_DICT("[email protected][email protected]@[email protected][email protected]");                            end      end    

3) Download and install the ActorManager mod (copy files to "GTA5 \ scripts" folder)

if you can't find the "AnimationIndex.txt" in that folder then start the game, press F6 and check again

open that file, there is the list of animations

keep that open, easier to work if you use windowed mode or second monitor

 

now go to "Preview Animatons", stay on Anim index, press Num5, switch to the opened txt file, select the anim you need

type in the number, zero not needed, press enter

go down in the menu (with Num2), select Play (Num5)

voilá :)

 

Now back to the code:

 

In the txt the anims have two part:

1) anim dict name

2) anim name

There is a " " (space) between them, be careful when selecting.

 

for example this is what I used in the code above:

05721 [email protected][email protected]@[email protected][email protected] getup_l_-180

anim dict name:

"[email protected][email protected]@[email protected][email protected]"

anim name:

"getup_l_-180"

 

As you can see in the code the anim name is used only once as the second parameter of TASK_PLAY_ANIM

The parameters for this:

http://www.dev-c.com/nativedb/func/info/ea47fe3719165b94

Scroll down to TASK_PLAY_ANIM or insert this on the searchbox and click "Find".

 

Regards,

Stormy

Link to comment
Share on other sites

Thanks for the tutorial, skyrayfox.

 

Can a synchronized scene accommodate arbitrary tasks (jump, pause, goto, sequences) under AI,

or is it reserved only for animations found in the dictionary?

Edited by ul1994
Link to comment
Share on other sites

 

void TASK_PLAY_ANIM(Ped ped, char *animDictionary, char *animationName,  float speed, float speedMultiplier, int freezeNSpeed,  int bodyPartNFreeze, float playbackRate, BOOL lockX,  BOOL lockY, BOOL lockZ)

 

I found out that the 5th and 6th parameter served different purposes. They are previously named

- int duration ---> int freezeNSpeed

- int lastFrame ---> int bodyPartNFreeze

 

[table]

Value : freezeNSpeedBehaviour-1Default (see bodyPartNFreeze)0Not play at allSmall valueSlow down animation speedSufficiently large valueFreeze player control until specific time (ms) has passed.

(No effect if bodyPartNFreeze is set to be controllable.)

[/table]

This parameter takes in duration in millisecond to disable player's control while animation is playing.

 

 

 

[table]

Value: bodyPartNFreezeBehaviourOdd numberLoop animation infinitelyEven numberFreeze animation at its last frameFor 0 to 31.

Multiple of 4.

Freeze animation at its last frame. Player is able to control.For 0 to 15

For 0x0 to 0xF

Animate entire bodyFor 16 to 31

For 0x10 to 0x1F

Animate upper bodyFor 32 to 47

For 0x20 to 0x2F

Animate entire body. Player can navigate while animation is playing.For 48 to 63

For 0x30 to 0x3F

Animate upper body only. Player can walk/run while animation is playing.For 0 to 255

For 0x00 to 0xFF

Play animation as describe aboveFor 256 to 511

For 0x100 to 0x1FF

Play garbled animation. This is similar to applying animal's animation to human ped.[/table] Edited by amoshydra
Link to comment
Share on other sites

Yo,

I didn't wanna trash the forums makin' another thread, so I'm asking here.. Have any of you found a NATIVE, apart from the one above, that lets you for example disable or exclude a bone during the animation or at least blend out that body part so it continues its motion from the previous animation. To make it easy to visualize, imagine Michael holding a coffee cup in his one hand, and the other arm swings in the usual motion. Thanks in advance!

Peace.

Edited by Hryniu
Link to comment
Share on other sites

  • 3 weeks later...

Has anyone worked out what the last few parameters of CREATE_SYNCHRONIZED_SCENE are?

 

I've set up a scene between two peds and they always teleport on top of each other and glitches. I need them to maintain both their positions! Any ideas??

Link to comment
Share on other sites

  • 3 weeks later...

Any idea why I'm getting this error when trying to run your example synchronized scene?

[LUA] GTALua/internal/extensions/CNativeReg.lua:70: CNativeReg:Call [AI/TASK_SYNCHRONIZED_SCENE]: Argument type mismatch (index 3 - got string expected number)

Didn't change anything, as you can see:

natives.AI.TASK_SYNCHRONIZED_SCENE(Suspect, scene1, "[email protected][email protected]", "flee_backward_shopkeeper", 1000.0, -4.0, 64, 0, 0x447a0000, 0)
Edited by DrDoom151
Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...

Thanks for the excellent research.

 

Have started the implementation of synchronized animation in Scene Director mod.

Just released a beta which has a preview functionality of synchronized animations and will make them recordable in a scene soon

 

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.