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 / FPS Game- Animating Guns

Author
Message
Zaibatsu
18
Years of Service
User Offline
Joined: 1st May 2006
Location: Lost in Thought
Posted: 3rd Nov 2009 06:17 Edited at: 7th Nov 2009 17:52
EDIT: I'm removing the downloads because they contain models from the Game Creators Store.

Alright, I've scrapped my last FPS project because it was becoming a large, semi-functional mess. I've decided to not even look at a shader this time until the actual game elements are done. It's going to be an endurance shooter like Nazi Zombies/Firefight/Horde or whatever. This is the first time I've tried to get an animated model working, and I've actually made some progress with it. Unfortunately, I didn't make enough progress with it.

I can either get the gun to display an idle animation while standing still, and a bobbing animation while moving; or I can get it to display a firing animation.

Anyways, Code:



My 2 different animation codes are:


and in my firing code:



If I comment out the


section, then the firing animation works fine, but the movement animation of course won't play. If they're both active (not commented out) then the movement animation seems to work, but the firing animation won't work.

Attatched is the media and project file if you need to mess about with it to get it working.

I'll also probably need help getting the reload animation to work.

Thanks for any help you can provide.

Zaibatsu
18
Years of Service
User Offline
Joined: 1st May 2006
Location: Lost in Thought
Posted: 4th Nov 2009 05:45 Edited at: 7th Nov 2009 17:52
I still haven't resolved this issue, but I have given the player multiple guns. Use the keys 1-4 to switch guns. The gun switching code isn't the best, so I'd like it if someone could give me some suggestions as to how to improve it.



I do still need help with the animation! Someone here must know how to fix this, and I ask that you please help me with it. New zip uploaded with updated project and media.

EDIT: Download removed

lil marioman
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: Canada
Posted: 6th Nov 2009 00:38
Now I'm not sure if this is your problem... but I'ma try my hand at it anyways.

When you're using your moving/idle code, it loops a certain animation NO MATTER WHAT. Meaning, if you're pressing a WASD key, then it loops the moving animation. If you're not pressing it, no matter what else you may be doing, it loops idle. What's happening is when you use 'Play Object' for the firing animation, it immediately loops over it with the idle/moving animation. I ran into this problem too in my FPS.

You could add flags to play the idle animation or not.

You could have a variables called FireState (for when the play is firing), ReloadState(for when they're reloading) and IdleState(for when the player is idle).

Example Code below.



Then, in your firing code, (and I'm assuming it's an automatic weapon here - if it isn't the code is a little different) add something like:


Also, in regards to your gun changing, I haven't found the time to implement it into my project yet, but it SHOULD work.

Get the MouseZ values every loop, and store them in a variable. Then, compare them with the older ones to see if they changed. If they did, then swap guns. Like so:



No guarantees that the above is correct, it's just half-pseudo code I generated from the top of my head. May need a little bit of tweaking to suit your needs.

Hope I helped! And good luck! I hope to see another FPS in the WiP section soon!







Zaibatsu
18
Years of Service
User Offline
Joined: 1st May 2006
Location: Lost in Thought
Posted: 7th Nov 2009 04:38
Thanks for posting, It's nice to know that at least someone was reading it. What you suggested made sense, but I guess I'm just not implementing it right. I'd appreciate if you could take a look at the new code and see if anything looks out of place.



Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 7th Nov 2009 06:34
Just an off-comment. Why use all caps for every command? In most programming languages all caps variables are used for constants. It also makes your code pretty horrible to look at :\
Zaibatsu
18
Years of Service
User Offline
Joined: 1st May 2006
Location: Lost in Thought
Posted: 7th Nov 2009 07:03
Quote: "Just an off-comment. Why use all caps for every command? In most programming languages all caps variables are used for constants. It also makes your code pretty horrible to look at :\ "


I think it makes it easier to read.

lil marioman
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: Canada
Posted: 7th Nov 2009 17:02
In my opinion, you should organise things into functions and subroutines. And eventually, when you get far enough, multiple source files.

It makes things easier to read, and IMO, it keeps the main loop less crowded.

Also, I THINK this should do it, I don't have Dark Physics, so I can't test it.

Commented some parts that I've changed, read them, especially lines 158-161



Also, sent you an email.



Satchmo
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 7th Nov 2009 19:41 Edited at: 7th Nov 2009 19:42
lil marioman is right Zaibatsu, USE SUBROUTINES, and even functions when you can, trust me, it will make navigating and modifying your code so much easier.

Most of my main loops look something like this

DO
Set cursor 0,0
Gosub this
Gosub that
Gosub Camera
sync
LOOP

Login to post a reply

Server time is: 2024-11-16 09:20:17
Your offset time is: 2024-11-16 09:20:17