Jump to content

  • Log In with Google      Sign In   
  • Create Account


how to handle character to vehicle controls?


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   -  Reputation: 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

Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 6729

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;
  }
}






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.



PARTNERS