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 have a simple problem (my second day)

Author
Message
Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 15th Feb 2004 21:44
i have a model loaded (the goblin model) and loaded the idle.x part.....then i made it so u can move it around with the arrow keys on a textured matrix... my problem is that when i move it it stops moving and just slide.....how do i make like a secondary anim. so it can like walk.....ill put in the code ...im very disorganized though so ya....

Dark
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 15th Feb 2004 21:55 Edited at: 15th Feb 2004 21:56
the play object and loop object functions should be called just once in order to see the animation take place.

Firstly, what your doing wrong is constantly calling the functions loop and play object within a do loop

Secondly, you need either play object or loop object, not both, play object plays the objects animation from start to stop, loop object plays the objects animation from start to stop and loops back to start again and continues this untill specified otherwise.

Try putting just a loop object command outside the do loop (above) and see what happens...

Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 15th Feb 2004 22:08
ok that helps, but how do i make it do the walk animation only when i pres the arrowkeys

do i have to hide the idle modle and replace it with the walking model? ....i dont know this is confusing

can someone give me a code snippet from mine that adds my "walk.x" model so when i press up it switches from idle to walk

Dark
Sjakie
21
Years of Service
User Offline
Joined: 17th Dec 2003
Location: Netherlands - Delft
Posted: 15th Feb 2004 22:53
Nope, its easy, you need something like this

Hope this helps you out

Juzt a dude who likez progging - Me loves RTS games
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 16th Feb 2004 00:48 Edited at: 16th Feb 2004 00:48
there is a brilliant example of this in the dark basic help files under animations...

sjakie has the right idea but incorrect implementation:

rem detect when key pressed
nanime = 0
if upkey() = 1 then nanime = 1
if downkey() = 1 then nanime = 1

rem ensures only performed once
if nanime <> oanime
if nanime = 0 then loop object :rem loop the idle animation
if nanime = 1 then loop object :rem loop the walk animation
oanime = nanime
endif

each animation you load into dark basic has a total number of frames, you have to know the start and stop frames of the specific animation you want to loop. say idle was from 1 to 20 and walk was from 21 to 40, so you would write:

loop object 1,01,20 for the idle animation
loop object 1,21,40 for the walk animation

Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 16th Feb 2004 02:18
ok thanks guys (or girls) i apriciate it!

Dark
Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 16th Feb 2004 02:25 Edited at: 16th Feb 2004 02:26
that leaves a slight problem though......its idle when i dont press the up or down key...so far so good BUT then when i press the up key it does the animation....then i release the key and it doesnt stop...

EDIT : the modle stops moving ut the animation doesnt

Dark
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 16th Feb 2004 03:07
is the idle part working?

if you implemented the code i showed you above correctly then it should work fine... post your entire code up and i'll take a look

Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 16th Feb 2004 03:08 Edited at: 16th Feb 2004 03:09
IM STARTING TO GET THIS!!! this is what i changed it to!!! (all on my own!!!

... i wasnt using te append....i was just loading it up like a normal object LOL

Dark
Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 16th Feb 2004 03:32 Edited at: 16th Feb 2004 03:33
now that i have the movement animations working can teach me how to do collisions please....and i do not have the money to go and but that premade colision thingy for fifteen dollars....im 10..im make 5 dollars a week (i have other things i feel the need to invest in

i want to randomize my matrix...to add some flavor to it....when i do he walks through the hills please tell me how to make it walk ON the hills

ONE MORE THING! when i randomize the matrix..can i round the hills...there so point....ouch (ugly)

Dark
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 16th Feb 2004 15:19
ok, in order to walk on the matrix, you need the know the height above each matrix point... to do this you use the get ground height command, i think it's parameters are matrix number, position x, position y. In your case the code should be something like:

rem log object position
posx#=object position x(1)
posz#=object position z(1)
posy#=get ground height(1,posx#,posz#)

what that should do is get the height of the matrix at point posx# and posz#, you then use this height stored in posy# to position your object. (check that the get ground height works).

rounding the hills take more work... it would be cool though if db had two types of randomise matrix implementations, one to totally randomise the matrix and the second to kinda make a random terrain with smooth hills.

Tim Ballisto
21
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Right behind you.
Posted: 16th Feb 2004 17:30
i had the same problem you just answered, but let me make sure i understand.

after the snippit you provided, you should set the object position y to posy# or a little bit above?
something like this?

oposz#=object position z(1)
oposx#=object position x(1)
position object 1,oposx#,posy#,oposz#
Tim Ballisto
21
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Right behind you.
Posted: 16th Feb 2004 18:26
hm... it doesn't seem to be working...
(it's a flying game and i can't seem to get the crash to be triggered)

posx#=object position x(2)
posz#=object position z(2)
posy#=get ground height(1,posx#,posz#)
if posy#<=object position y(2) then crash=1
print crash

it prints 0 no matter where i am
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 16th Feb 2004 20:34
i think that should be the other way around:

if object position y(2) <= posy# then crash = 1

posy# stores the "ground height" the way you sorted the variables makes the code check if the ground height is less than the object height (which is nearly always so especially for a flying game )

the re-arranged code above should set crash = 1 when the objects height is less than or equal to the ground height which makes more sense...

ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 17th Feb 2004 21:31
second day and doing 3d.
i still cannot (be bothered to) do 3d, and i have been using db for over a year.
Guitarman
21
Years of Service
User Offline
Joined: 31st Jan 2004
Location:
Posted: 21st Feb 2004 16:57
ON the topic of 3d animation, i have an object that walks when you press upkey and stops when you dont. NOw i nedd to get it to play a different animation when i press spacekey. I tried both append object and append object animation. Can someone help me?The way i have it now, there are two objects, one for attack and one for move. if one is showing then the other is hidden. Is there a way i can do this with one model?

Login to post a reply

Server time is: 2025-05-23 12:19:04
Your offset time is: 2025-05-23 12:19:04