Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
DynamiteKaitorn

Jumping & Crouching Animations? [3D models]

Question

This is two animation questions I'm a little stuck on.

 

Is it possible to define an animation for when the player is in the air? (by jumping and/or falling)

 

and is there any way to properly implement crouching animations for models? I've tried to use "Player.CrouchSprite" with a sprite name both identical and different to my standard frame names and I even changed the "FrameIndex" in MODELDEF to match the crouch sprite letters but both failed...

Share this post


Link to post

14 answers to this question

Recommended Posts

  • 2

DON'T USE THAT METHOD! Because it doesn't detect 3D floors, standing on actors or basically anything that isn't the very bottom floor, it will look extremely buggy.

It's way better to use TNT1 A 0 A_JumpIf(velz!=0, "Jumping") in all states. This way, when you fall or jump up the animation in the Jumping state will play. Also remember to give all frames of the jumping animation this codepointer: A_JumpIf(velz==0, "Spawn") so when the player stops falling/jumping it will go back into the default state.

 

You can also use TNT1 A 0 A_JumpIf(height<50, "Crouch"), so when the player crouches it will go into the Crouch state. As for animating movement here i have no idea.

Share this post


Link to post
  • 1
1 hour ago, DynamiteKaitorn said:

Edit:

Also if this did work, how would I even change the animation of my 3D model to the jumping animation and back to standing when I land?

ok so I just tested it:

 

Script 998 ENTER
{
    While (TRUE)
   {
        if((GetActorZ(0) - GetActorFloorZ(0)) > 2)
            {
                Print (s:"JUMPING");
            }
        delay (1);
    }
}

 

This works without a problem.
If it doesn't work for you then you are compiling it wrong. Simple as that.

And how it could work , here is a suggestion:
 

In Decorate: ------------------------

 

Actor TokenJumping : Inventory

{

 Inventory.MaxAmount 1

}

 

--------------------------------------

 

In Acs: -----------------------------------------

 

Script 998 ENTER
{
    While (TRUE)
   {
        if((GetActorZ(0) - GetActorFloorZ(0)) > 2)
            {
                //Print (s:"JUMPING");

               GiveInventory("TokenJumping",1);          
            }

        else

            {

               //Print (s:"Not Jumping");

               TakeInventory("TokenJumping",1);

            }
        delay (1);
    }
}

--------------------------------------------------

 

In Decorate Again: ----------------------------

 

Actor YourPlayer

{

Bla bla bla

States

     {

     See:

     TNT1 A 0 A_JumpIfInventory("TokenJumping",1,"SeeJumping")

     //Your normal movement

     Goto See

 

     SeeJumping:

     // Your air movement

     TNT1 A 0 A_JumpIfInventory("TokenJumping",1,"SeeJumping")

    Goto See

     }

}

-----------------------------------------------------

Share this post


Link to post
  • 0
On 2/4/2019 at 10:20 AM, DynamiteKaitorn said:

This is two animation questions I'm a little stuck on.

 

Is it possible to define an animation for when the player is in the air? (by jumping and/or falling)

 

and is there any way to properly implement crouching animations for models? I've tried to use "Player.CrouchSprite" with a sprite name both identical and different to my standard frame names and I even changed the "FrameIndex" in MODELDEF to match the crouch sprite letters but both failed...

 

 

For jumping you could use ACS , and the distance of the player from the ground can be caluclated if I recall with (GetActorZ(0)- GetActorFloorZ(0)).
Info here :   https://zdoom.org/wiki/GetActorZ     ,      https://zdoom.org/wiki/GetActorFloorZ
 

 


And for the crouching you can check this thread of the old way with ACS:
https://forum.zdoom.org/viewtopic.php?f=15&amp;t=33638 
//But the Player.viewHeight can be obtained by this I think as well https://zdoom.org/wiki/GetActorViewHeight

 

Or you can use the "GetCrouchFactor" function as well , which I have not used to this point tbh

Share this post


Link to post
  • 0
1 hour ago, Dude27th said:

(GetActorZ(0)- GetActorFloorZ(0))

 This causes an error "Invalid Statement" when I try to compile. Mind expanding on this a bit?

 

1 hour ago, Dude27th said:

And for the crouching you can check this thread of the old way with ACS:
https://forum.zdoom.org/viewtopic.php?f=15&amp;t=33638 
//But the Player.viewHeight can be obtained by this I think as well https://zdoom.org/wiki/GetActorViewHeight

 

Or you can use the "GetCrouchFactor" function as well , which I have not used to this point tbh

 

The ZDooM link is exceptionally out of date, I have no idea how I am meant to utilise GetActorViewHeight and "GetCrouchFactor" is either outdated as well or straight up not supported for GZDBBF UDMF format. >_>

Share this post


Link to post
  • 0
8 hours ago, DynamiteKaitorn said:

 This causes an error "Invalid Statement" when I try to compile. Mind expanding on this a bit?

 

It is a conditional. Of course it says "Invalid Statement",  you are supposed to use it inside an if() in ACS and the result of that is your distance from the floor.
Something like:

 

if(GetActorZ(0) - GetActorFloorZ(0)> 5)

{

   //Your code here 

}

 

In simpler terms:

If the distance between the player and the floor is bigger than 5 (Don't remember the scale of it) , it executes the code between the { }

 

 

Share this post


Link to post
  • 0
8 hours ago, DynamiteKaitorn said:

The ZDooM link is exceptionally out of date, I have no idea how I am meant to utilise GetActorViewHeight and "GetCrouchFactor" is either outdated as well or straight up not supported for GZDBBF UDMF format. >_>

 

Well if GetActorViewHeight doesn't works with (0) try giving your player a unique tid with "Thing_ChangeTID" and then use that tid with "GetActorViewHeight".
If you don't  know how to use it still , you could research it 

Share this post


Link to post
  • 0

Script 998 ENTER
{
    While (TRUE)
   {
        if(GetActorZ(0) - GetActorFloorZ(0) > 2)
            {
                Print (s:"JUMPING");
            }
        delay (1);
    }
}

 

For now I'm just testing to see if it fires the script when I jump and so far, GZDooM IS registering it but it wont display the print statement. Any reason it fails to fire/execute the IF statement?

 

 

And for the crouching part, I decided to look it up on ZDooM wiki and I'm still stuck. :l

Share this post


Link to post
  • 0

Try adding parentheses to make it clear in what order you want the operations to be executed.  It might be doing GetActorFloor(0) > 2 first, and then subtracting that from GetActorZ(0).  Also, try Log instead of Print.

Share this post


Link to post
  • 0
13 hours ago, DynamiteKaitorn said:

Despite the extra brackets and the use of log, it fails still... >_>

 

if(( GetActorZ(0) - GetActorFloorZ(0) ) > 2) <-- That way still fails ?

Share this post


Link to post
  • 0
5 hours ago, Dude27th said:

 

if(( GetActorZ(0) - GetActorFloorZ(0) ) > 2) <-- That way still fails ?

 

17 hours ago, DynamiteKaitorn said:

Despite the extra brackets and the use of log, it fails still... >_>

 

 

Edit:

Also if this did work, how would I even change the animation of my 3D model to the jumping animation and back to standing when I land?

Share this post


Link to post
  • 0

Okay so after making an external WAD file I see it IS working but for some reason with my main .pk3 file, it crashes GZDooM... Not even sure why :l

 

EDIT:

After fixing up the WAD file so it actually runs (apparently I forgot a few details so it wasn't reading it correctly) it now crashes once I jump and move.

 

EDIT 2:

I found the issue in your code. You accidentally made the code infinitely loop between two states, causing GZDooM to crash. the "SeeJumping" Didn't need the A_JumpInInventory.

 

Edit 3:

I'M SO CLOSE! I just need to find a way to clean the animation (since models have a habit of wanting to revert to default state, making every frame smooth (annoyingly))

 

     See:
     POSS BCDEF 6 A_JumpIfInventory("TokenJumping",1,"SeeJumping")
     Goto See
     
     SeeJumping:
     POSS Q 8 A_JumpIfInventory("TokenJumping",0,"SeeJumping2")
     Goto SeeJumping
     
     SeeJumping2:
     POSS QRSR 8
     Goto see

 

Now to tackle the crouching state!

 

 

Edited by DynamiteKaitorn

Share this post


Link to post
  • 0

Whelp! I have my crouching animation and my jumping animation sorted out! But err... ducking whilst in the air causes the model to go invisible until another state is entered. (Standing seems to play the jump animation THEN go back to standing) :l

Share this post


Link to post

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
×