Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

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

    1. Red Dead Redemption 2

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

    1. Grand Theft Auto Series

    2. GTA VI

      1. St. Andrews Cathedral
    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. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. 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. 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
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Please be aware that this is not a tutorial request forum! Use the appropriate topic for the effect.
skyrayfox

[Tutorial] Creating synchronized animations (GTALua)

Recommended Posts

skyrayfox

[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!
  • Like 8

Share this post


Link to post
Share on other sites
ffzero58

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.

Share this post


Link to post
Share on other sites
Freakyy

Very nice tutorial!

Do you mind if I add it to the wiki?

Share this post


Link to post
Share on other sites
sodanakin

Thank you very much for this will be using this for sure!

Share this post


Link to post
Share on other sites
skyrayfox

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 !

Share this post


Link to post
Share on other sites
dehan

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

Share this post


Link to post
Share on other sites
skyrayfox

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, "")

Share this post


Link to post
Share on other sites
dehan

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

Share this post


Link to post
Share on other sites
MrPancakes

Very thorough tutorial, helped me alot. Thanks bro.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
stormy.scp

 

 

[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

Share this post


Link to post
Share on other sites
ul1994

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

Share this post


Link to post
Share on other sites
amoshydra

 

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

Share this post


Link to post
Share on other sites
Luucky

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

Share this post


Link to post
Share on other sites
jordRiot

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??

Share this post


Link to post
Share on other sites
ayylmao420

Anyone at all managed to do synchronized animations in scripthook dot net? :/

Share this post


Link to post
Share on other sites
DrDoom151

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

Share this post


Link to post
Share on other sites
darkphoenixxx

Thank your for tutorial, its awesome!

Share this post


Link to post
Share on other sites
elsewhat

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

Share this post


Link to post
Share on other sites
Dmitrysass

That awesome)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.