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.

Newcomers DBPro Corner / Strange animation loop problem, needs help

Author
Message
pc nerd
User Banned
Posted: 15th Apr 2009 01:36 Edited at: 15th Apr 2009 06:15
ok, so i have it set to where when im walking i can go to running then back to walking, then when i do nothing i do my idle animation, this all works fine and dandy. but i tried to empliment an attack animation to play when i press ctrl, but nothing happens because when im pressing the up key then my walking animation is always true? here is my code.

my animation set up



my command set up

ive tryed difrent things here as none worked
i even tryed a mouse click here to


and then my whole animation coad set up



any help would be appreciated

dweeb
pc nerd
User Banned
Posted: 15th Apr 2009 02:05 Edited at: 15th Apr 2009 06:15
OK guys i got it to work but i still have on problem i cant figure out.it only works if i hold down the ctrl button, i need it to play when i hit the control button.

here is all i put for it to work when i hold down the control button

if keystate(200)=1 and ENERGY#=100 and keystate(157)=1 then animestate#= 3

dweeb
pc nerd
User Banned
Posted: 15th Apr 2009 03:22 Edited at: 15th Apr 2009 06:16
so pretty much all i need to know is how can i make it to where the mouse is held down for a certain amount of time when i just click the mouse, im sure this is what i need.

dweeb
mike5424
15
Years of Service
User Offline
Joined: 30th Mar 2009
Location:
Posted: 15th Apr 2009 14:27
ok your last post confused me but im sure this is what you mean:



or if you want it to wait this may work (dont know though)

3000 means wait 3 seconds but you can change it

www.madninjas.co.nr we are mad and we are ninjas
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 15th Apr 2009 17:47 Edited at: 15th Apr 2009 17:48
The problem is this line, I believe:

if keystate(200)=1 and animestate#= 2 and keystate(157)=1 then animestate#= 3

It will only work if the user is pressing both the upkey and the controlkey.

Another problem could be coming from here:

if keystate(200)=0 then animestate#= 0

Because of this line, if the user is not pressing the upkey, the object will not animate at all.

Try changing the LOOP OBJECTs to PLAY OBJECTs and changing the line above to:

if keystate(200)=0 and animestate#=1 then animestate#= 0


@mike

NEVER use wait in your program loop. This drastically lowers the FPS rate.

Also, I'm pretty sure that's not what he meant. The solution is rarely as easy as naming a command for someone. You need to read posts more carefully if you want to try to respond effectively.



pc nerd
User Banned
Posted: 15th Apr 2009 23:25
@BMacZero

well, ok, im not shure you understand me, the

if keystate(200)=0 then animestate#= 0
is for my idle animation, this does have a animation set to it.

like i said though, my attack animation works good, but it only works when i hold down the button, not when i juct click it. when you just click the button for a first person shooter then the guy shoots his gun then plays a animation to reload his gun. well i have to acully hold the button for the whole animatin to play through. when i just click the button he just jerks a little.

I need it to where all i have to do is click my mouse once then the whole animation plays through, then after that he resorts back to his walking animation.

dweeb
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 16th Apr 2009 00:06
Ah, that's clearer. I still think that line is the problem, though.

In this code:


The program checks to see if the upkey is not pressed. If it isn't, it sets the state to 0.
Then it checks to see if the keys for attacking are pressed. If they are, it sets the state to 3.

Now, if you just press the keys once, the second if statement triggers once, setting the state to 3. However, if the keys are released, the first if statement will trigger on the very next loop and set the state back to 0, and the program will forget about the attack and go back to the idle animation.

To fix this, try this code:

That should make it so the character will only become idle after the attack animation is finished.
(For this to work, you will also need to change the fourth line to PLAY OBJECT rather than LOOP OBJECT)



pc nerd
User Banned
Posted: 16th Apr 2009 00:38
ok, becouse line animate 0 is my idel animation this did not work

if keystate(200)=0 and object playing(2)=0 then animestate#= 0
if keystate(200)=1 and animestate#= 2 and keystate(157)=1 then animestate#= 3

this is what happened so mabey you can understand why it did not work becouse i have no clue myself,lol.

when i placed the coad then i chaged the loop to play. my guy keept walking then would not stop walking, then the attack animation never played at all.

if it helps at all here is the order of the animations




thanks for your help so far though, im shure there is a way right,lol. if theres a will theres a way.

dweeb
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 16th Apr 2009 01:12
Quote: "(For this to work, you will also need to change the fourth line to PLAY OBJECT rather than LOOP OBJECT)"


PC nerd, I think you missed a bit! ^_^

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
pc nerd
User Banned
Posted: 16th Apr 2009 01:19
@Dream And Death
ohh no, i got that, it still just does nothing with the above coad.
mabey i should go and look at a first person shoting tut to see how they did it with the shoting then mabey i can do the same. does anyone know of a good shooting tutt for an example i could gleem at?

dweeb
pc nerd
User Banned
Posted: 16th Apr 2009 01:23
well, i found this, mabey it will help a bit, thanks guys, im not shure if it will but right now ill try anything.

[href]null[/href]

dweeb
pc nerd
User Banned
Posted: 16th Apr 2009 09:52
ok, i figured this out and it works, i would like to explain so if anyone has this problem with there mouse button or any other key then you can just have one click per animation, now what i did was, and i thought about this for a long time before i figured out a way to impliment it.

First i made a trigger zone that was as big as my whole level.
then i made it to where if me, the player had a collision with the trigger zone it would play my animation, then to stop the animation all i had to do was turn off the trigger zone. here is my coad if it helps any one.

first


then i


dweeb
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 16th Apr 2009 11:44


You still appear to have LOOP OBJECT on the last line ^_^

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
pc nerd
User Banned
Posted: 16th Apr 2009 12:07 Edited at: 16th Apr 2009 12:09
@Dream And Death

wrote
Quote: "You still appear to have LOOP OBJECT on the last line ^_^"


What does this matter? it works great the way its set up. it did not work with play object no matter how hard i tryed becouse you cant play 2 animations at the same time.so my walking animation was conflicing with my play animation, so when i place a trigger zone to activate my loop animation it works great. my attack animation plays like its supost to becouse the trigger set my attack animation true. witch turned off my other animations.even with this set up like it is i still can not get play object to work. it just will not work for me for some strange reason.
but i do not care for the fact that its working great becouse i have the trigger set to a timer.

dweeb
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 16th Apr 2009 12:28
Quote: "if keystate(200)=0 and object playing(2)=0 then animestate#= 0
if keystate(200)=1 and animestate#= 2 and keystate(157)=1 then animestate#= 3
"

Object playing(2) will (afaik) only return a 1 if the object is PLAYing an animation, not LOOPing one. Though I could be wrong.

I admire your workround, but it seems bizarre that you need one - this is really basic stuff. Any of the more experienced coders on the board will have coded animations like this a thousand times over. Perhaps one of them could weigh in with an insight?

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 16th Apr 2009 16:48
Quote: "Object playing(2) will (afaik) only return a 1 if the object is PLAYing an animation, not LOOPing one."

Actually, I believe OBJECT PLAYING() returns a 1 if the object is playing or looping, while OBJECT LOOPING() only returns a 1 if the object is looping.


I guess that's a workable method for animation. At least, from here there is one small change we can make to simplify it even more:

Why use a trigger zone like that? Just set a flag when you want the animation to play and you can avoid that massive box confusing Sparky's when you need it for other things:





pc nerd
User Banned
Posted: 16th Apr 2009 22:36
LOL BMacZero

I was just thinking about this very thing last night before bed time. i thought why use triggers at all if all ineed to do is use a timer with a flag set making the animation play. same theroy but withiut the trigger. i do thank all of you guys for trying to help me. i do wish i knew why my play object would not work though.

dweeb

Login to post a reply

Server time is: 2024-09-28 04:12:24
Your offset time is: 2024-09-28 04:12:24