Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

how to handle character to vehicle controls?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 drwbns   Members   

103
Like
0Likes
Like

Posted 04 October 2012 - 08:32 PM

Hi guys, I was wondering how to structure classes that can handle player movement but also allow to switch to vehicle movements. I found a post here that looks correct, but it's left me baffled as a novice. Any further explanations to this system?

http://www.ogre3d.org/forums/viewtopic.php?f=10&t=70229#p458355

#2 Ashaman73   Members   

13714
Like
3Likes
Like

Posted 04 October 2012 - 11:25 PM

You can define an controller interface, which controls the movement of an entity depending on given input, like


class ControllerInterface
{
  void inputForward() = 0;
  void inputLeft() = 0;   
}

Then you can inherit and implement this interface for different game entities.


class CarController : ControllerInterface
{
 ....
}
class CharacterController : ControllerInterface
{
....
}

In your player class switch the controller depending on the players state:


class Player 
{
  CharacterController charController;
  CarController carController;
  bool inCar;

  ControllerInterface getController() {
	 return inCar ? carController : charController;
  }
}


Ashaman

 

Gnoblins: Website - Facebook - Twitter - Youtube - Steam Greenlit - IndieDB - Gamedev Log





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.