It is currently Tue Oct 24, 2017 2:45 am

All times are UTC - 5 hours




 Page 1 of 1 [ 5 posts ] 
Author Message
 Post subject: Caligari VMK 6 Material Editor
PostPosted: Tue Feb 13, 2007 7:07 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
This video shows how to add the ability to crouch to the player class. Crouching is a key press-and-hold type event.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 13 - Adding Crouch Ability
PostPosted: Tue Oct 16, 2007 3:57 pm 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
Hello, im gonna show how you can make so the speed while crouching is slower than standing.

First make a public funtion in Camera.h This function looks like this:

void Camera::SetSpeed( float fLinearSpeed )
{
    m_fLinearSpeed = fLinearSpeed;
}


Now, in Player.cpp you add SetSpeed( 2.0f ); at the top of case PS_CROUCH and SetSpeed( 5.0f ); at the top of case PS_GETUP. Of course you can use whatever speed you like.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 13 - Adding Crouch Ability
PostPosted: Wed Oct 17, 2007 5:32 am 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
that's one way to do it... there are about a zillion other ways, and I don't think your solution is the most elegant, as you now have to go deeply into your code if you want to change the movement speed.



If you do want to stick to this model, it migth be a good idea to use #define SPEED_WALKING and #define SPEED_CROUCHING (or something like that), but I think it would be better to solve this problem in a different way.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 13 - Adding Crouch Ability
PostPosted: Wed Oct 17, 2007 5:36 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
perhaps adding some member variables to the player class to keep track of the regular speed and the crouch speed, would be enough. Then when you call SetSpeed, you would indicate with a parameter whether you are changing the speed to normal, or slow.


Offline
 Profile  
 
 Post subject: Re: GameDev VMK 13 - Adding Crouch Ability
PostPosted: Wed Oct 17, 2007 5:39 am 

Joined: Tue May 01, 2007 2:55 pm
Posts: 96
Location: Behind you
in that case I would still prefer defines (unles you are actually modifying these speeds during the game) as you are otherwise using variables as constants. That may be personal preference, but I think there simply has to be some more elegant way to do this.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron