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 / Kirby Limb problem

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Mar 2008 00:58 Edited at: 2nd Mar 2008 01:04
Hey Guys!

I have this problem with my Kirby animation.
I put up the simple code for it:



You will need to download the file attached and place the folder "textures" in with the DBC code.

This example generates the Kirby figure and adds animations to it. The left and right movements work fine. The squash movement works to. But when I jump, The legs twist back like normal, then twist forwards to land(like normal), while the arms move up(like normal), and down again(like normal), the arms stay down! I don`t know why the arms stay down, I have tried rotating them back to 0 degrees, but they just go back down!

Can someone please run through the code and find why that is so?

Thanks in advance, TheComet

Oooooops!!! I accidentally formated drive c.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Mar 2008 04:33
What seems a bit strange to me is that you don't have the arms and legs as limbs. You have them as separate objects that you position. If they were limbs, they would be carried with the main object and you'd rotate them independently or offset them relative to the main object. You could porgram all of the animations ahead of time and set key frames for each set of movements. Then when an action occurs (move, jump, whatever) you
Play Object obj,framestart,frameend

Here's an example. Use left key or right key to move arms:
autocam off



That being said,

Functions treat the variables in them as local (they don't hold their value when you exit the function). If you don't pass a variable to a function or assign it to a global array (an array that has been created in the main program not the function), the variable will have a value of zero in the function. Take the function walk, for example:



frzv will never = 1 when the function starts nor will frz be > 30 or > 310. You are not passing frzv to the function with a value nor are you establishing it's value before the conditional tests. Later on you use frz in your rotation calculation when kirby walks. I think this is what's making the inconsistancy with the arm positions.

Enjoy your day.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 2nd Mar 2008 08:18
Quote: "frzv will never = 1 when the function starts nor will frz be > 30 or > 310."


Really? So any variable in a function that has not been passed down, you can not change within the function? How come the walk function is working then?

Quote: "What seems a bit strange to me is that you don't have the arms and legs as limbs. You have them as separate objects that you position."


That makes it easier to rotate the arms.

I didn`t know about the command Set Object Keyframe... That`s going to make it a lot easier!

Thanks Latch!

TheComet

Oooooops!!! I accidentally formated drive c.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Mar 2008 18:25
Quote: "Really? So any variable in a function that has not been passed down, you can not change within the function? How come the walk function is working then?"


Variables can be changed within the function if they are acted on within the function. If they have no value when the function begins, or a value isn't initially passed to them, they will be 0.
Check out this example. In add1, a will never = 1 because it isn't passed to the function so b cannot = 1000. In add2 both a and b have the values that are passed to them. Naming the variables the same outside as they are inside doesn't mean the value will be carried over (except if it is an array that was dimensioned outside of the function).



Quote: "How come the walk function is working then?"

It seems to be working, but I think you may be forcing it to behave as you want. For example, if I want the variable Var to be caluclated so it equals 5, I might have something like
Var = x + y

and hope that x and y have values that when added = 5. However, if I notice Var is not equaling 5, I can force it to:

if x+y =5
Var=x+y
else
Var=5
endif

Anyway, after reconsideration, I'm not sure how the arms should be when kirby is walking. Midway up? Or down near his feet? One of the problems is with the rotation order of the objects. I noticed that when you turn Kirby right his arms are up, and when you turn him left his arms are down. This has to do with the order DBC calculates X Y and Z. Try reversing the order of rotation by setting each objects rotation order with
SET OBJECT ROTATION ZYX objectnumber

after each object is created. I tested it out and kibys arms stayed at the same level when he was turned left or right.

Enjoy your day.

Login to post a reply

Server time is: 2026-07-05 14:21:08
Your offset time is: 2026-07-05 14:21:08