Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / I need help with idle to walk transfermation

Author
Message
DoobieDoom
12
Years of Service
User Offline
Joined: 16th May 2011
Location:
Posted: 17th May 2011 02:38
OK so I've been ripping my hair out trying to get my idle.x to append to walk.x, when upkey()=1, then back to idle when upkey()=0 or something along those lines.

HELP ME PLEASEEE

code would be much appreciated :p
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 18th May 2011 02:43 Edited at: 18th May 2011 02:45
Quote: "OK so I've been ripping my hair out trying to get my idle.x to append to walk.x, when upkey()=1, then back to idle when upkey()=0 or something along those lines."


These are two quite different things. When you say APPEND and supply the names of two X files, one could assume that you mean you have two of the same object saved as two different files, one with a walk animation and one with an idle animation. Your first goal is to add the idle animation from idle.x to the walk.x object. Based on this assumption, you'll want to:

1. Make sure both files are in the same directory (this makes things easier)
Quote: "...trying to get my idle.x to append to walk.x,"

2. The wording suggests loading walk and appending idle to it - so we'll take this approach. Load walk.x as a DBC object:



3. You'll need to know which frame you want to start the new (idle) animation from. Since walk.x is loaded first, we'll add the new animation after the last frame of walk.x. Finding this frame is not too hard:



4. Now we need to do the actual appending of the animation from idle.x to walk.x


That should be it for the first part of your question. Walk.x is the only loaded object at this point and it contains both animation sets fro walk.x and idle.x in that order. Let's take a gamble that the start frame of the walk animation is frame 1. We can figure out the start and end frames of each set of animations from the information we already know. This will help lead us to the second part of your question.



Notice how we used total object frames() to find the end of the idle animation. This is because we added that animation to the end of objwalk.

Now, we need a trigger (a key press) to switch between the animations. We'll use the upkey() as in your question:



Enjoy your day.
DoobieDoom
12
Years of Service
User Offline
Joined: 16th May 2011
Location:
Posted: 18th May 2011 16:35
Well first off thank you so much for responding! This is very helpful.

I think I should of mentioned that what I'm doing is in 3D, so I'm assuming "if upkey()=0 and animation playing(objwalk)=0" was ment for 2D since I got an error at this line.

I attempted changing "animation" to object, however I got another error on the next line "set object frame objwalk,startidle#" saying the frame does not exist.

I had "models/idle.x" loaded as object 1 before, my goal is to stop idle and play walk when the upkey() or downkey() is pressed. Shouldn't I have to load both the idle and walk?

Before I was trying something along the lines of "load object "models/idle.x",1 : append object "models/walk.x"

I am not sure if that was exactly what it was, but of course I couldnt get it to work, I tried using the pre-made 3D walking example in DBC but was frustrated relentlessly for a good 5 hours heh.

Thanks again though, I'll keep playing with your example and see if I can't get it to work
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 18th May 2011 22:10 Edited at: 18th May 2011 22:14
Quote: "I think I should of mentioned that what I'm doing is in 3D, so I'm assuming "if upkey()=0 and animation playing(objwalk)=0" was ment for 2D since I got an error at this line."


OOPS! Sorry about that! I used the wrong command! ANIMATION PLAYING is for movies. I meant to use OBJECT PLAYING. In fact, there are several times in the code where I used animation <something> instead of OBJECT < something>. I've updated the block with a complete example not made in as much haste as last time. I've changed the method slightly, accounting for loading idle.x first. It's basically the same, with a few changes.



Quote: "I had "models/idle.x" loaded as object 1 before, my goal is to stop idle and play walk when the upkey() or downkey() is pressed. Shouldn't I have to load both the idle and walk?"

That's fine to load either first, in this case idle.x. That makes more sense than the way it was worded at the top. And no; both do not have to be loaded. The idea behind the process is this:

1. On your hard drive are a series of the SAME model each saved as a different file.

2. Each model has it's own animation set

3. You load only ONE of these models as an object in DBC - that is if you only have 1 instance of this model in your game. If, for example you had 10 ninjas or something, then you would load the base model 10 times - in this case, the idle.x

4. Once the base model is loaded, you then APPEND additional animation sets to that object. You keep track of the start and end frames for each set and you play or loop those specific sets according to the action required for your game.

If there is still a problem, try loading the individual objects and running their animations to see if they even have animations and also to get an idea of their frames. Try something like :



This should give you an idea if your objects will even animate and what their start and end frames are.

Then, try playing with the other code I posted before.

Enjoy your day.

Login to post a reply

Server time is: 2024-04-24 21:09:41
Your offset time is: 2024-04-24 21:09:41