Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Camera, Player, and GameObject Architecture


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
4 replies to this topic

#1 roguan   Members   -  Reputation: 108

Like
0Likes
Like

Posted 02 December 2012 - 06:43 AM

I'm currently refactoring.

I want my camera to follow a player, rather than being completely detached in third-person.

Goal: Allow a third-person camera while reserving the right to attach the camera to arbitrary objects.

What are some alternatives when constructing the player, camera, and game objects to allow this?

I currently have:
Input -> InputManager -> Camera => Modified Camera Position/Orientation

I've considered attaching the camera to an object (for instance, the player), and allowing the camera to modify the player position (since the camera receives the input). But this seems ludicrous!

Should the InputManager be provided with which object it should affect? And, if the camera happens to be attached to the affected object, that object is responsible for updating the position/orientation of the camera?
Input -> InputManager -> PlayerControlledObject -> Camera => Modified Camera Position/Orientation

Could anyone point me to a good example of how to do this, which allows for a good amount of flexibility in the future?

Thanks!

Using : JOGL 2.0

Sponsor:

#2 Neglected   Members   -  Reputation: 111

Like
1Likes
Like

Posted 02 December 2012 - 01:41 PM

If you are using component-entity architecture (not sure if you are since you didn't specify), you could just create a CameraComponent and attach it to any entity with a Transform (x, y, scale) component. This allows you to attach the camera to any entity.

#3 roguan   Members   -  Reputation: 108

Like
0Likes
Like

Posted 02 December 2012 - 03:33 PM

Fabulous! This is my current approach. It seems sustainable. Is it common?
Much appreciated.

#4 Neglected   Members   -  Reputation: 111

Like
0Likes
Like

Posted 02 December 2012 - 04:56 PM

Not sure, but it was the first thing that came to mind.
The way I would do it is every frame, get the camera to get the Transform component of the Entity it is attached to, and then, before you draw anything, push a Transform onto the stack, translate everything to that Transform location, THEN draw your stage, pop the Transform, and then draw your GUI or what have you.

#5 roguan   Members   -  Reputation: 108

Like
0Likes
Like

Posted 04 December 2012 - 02:04 PM

Hey Neglected,
Thanks for your reply, the component method seems to be working very well for me!

Good insight, mate.




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