Mount to camera
by Tim Doty · in Torque Game Builder · 03/13/2005 (10:45 am) · 17 replies
I know you can mount the camera to an object, but can you mount an object to the camera? When I tried
$object.mount(sceneWindow2D);
I got "object is not in the same scenegraph" as an error. Is this not possible, or what am I doing wrong?
$object.mount(sceneWindow2D);
I got "object is not in the same scenegraph" as an error. Is this not possible, or what am I doing wrong?
About the author
#2
Are not the two practically the same thing? I suppose not if your controlling a character by moving the camera but that does seem a little odd.
I've been thinking about tha camera recently and I was thinking that when we add pathing support to objects, it would make sense just mounting the camera to the object and doing the fancy movement on the object.
- Melv.
03/14/2005 (9:59 am)
No, that's not a valid command although I'm not happy with the error-message it gave you so I'll look at that.Are not the two practically the same thing? I suppose not if your controlling a character by moving the camera but that does seem a little odd.
I've been thinking about tha camera recently and I was thinking that when we add pathing support to objects, it would make sense just mounting the camera to the object and doing the fancy movement on the object.
- Melv.
#3
The camera is mounted to the player object with a force. Consequently the camera view "floats" around the player object. Now for the HUD I want objects that are stationary in the view. The problem here is that if I mount them to the player object they get rotated with the player. Hence, I would like to mount them to the camera.
Maybe there's another way to do this, but if so I haven't been able to figure it out. (Well, I could make the player stationary, make everything move around him, do new camera positions and generally have a heck of a time trying to model the force-mounted-camera and then simply have the HUD items be stationary, but it is that situation I was trying to avoid by using the force-mounted-camera in the first place.)
Since the error message is puzzling would it help for me to post code? It'll have to wait until I'm home, but I can certainly do that.
Thanks again, any help you're able to give me is greatly appreciated.
03/14/2005 (10:16 am)
Thanks for the reply! It seems logical to me to (be able to) mount an object to the camera. There may be another way of getting what I want with how I'm doing things, but if so I can't see it.The camera is mounted to the player object with a force. Consequently the camera view "floats" around the player object. Now for the HUD I want objects that are stationary in the view. The problem here is that if I mount them to the player object they get rotated with the player. Hence, I would like to mount them to the camera.
Maybe there's another way to do this, but if so I haven't been able to figure it out. (Well, I could make the player stationary, make everything move around him, do new camera positions and generally have a heck of a time trying to model the force-mounted-camera and then simply have the HUD items be stationary, but it is that situation I was trying to avoid by using the force-mounted-camera in the first place.)
Since the error message is puzzling would it help for me to post code? It'll have to wait until I'm home, but I can certainly do that.
Thanks again, any help you're able to give me is greatly appreciated.
#4
I also had other layers that I wanted to remain stationary during shake.
Melv, would a startLayerShake() command that works like a startCameraShake be feasable, or am I missing something obvious about why that would make no sense? :-)
03/14/2005 (10:26 am)
@Tim: I ran into the same issue, but in a completely different way (par for the course for me :-) ). I was trying to get a HUD that was made of T2D objects, but that wouldn't be affected by camera shake.I also had other layers that I wanted to remain stationary during shake.
Melv, would a startLayerShake() command that works like a startCameraShake be feasable, or am I missing something obvious about why that would make no sense? :-)
#5
You can create as many scenegraphs and windows as you like so you could just create a scene/window specifically for the HUD objects only and position over the other window (probably centrally) where you like.
- Melv.
03/14/2005 (10:30 am)
Guys,You can create as many scenegraphs and windows as you like so you could just create a scene/window specifically for the HUD objects only and position over the other window (probably centrally) where you like.
- Melv.
#6
03/14/2005 (10:49 am)
@Melv: That occured to me and I tried it, but it just overwrote the entire window so I thought you could only have one scene graph. I must have had something cocked up, I'll do it that way. Thanks!
#7
03/14/2005 (11:27 am)
Thanks, Melv. I'm off to try that right now!
#8
Lots of lots of nice stuff to discover. Isn't that the mark of a fun engine? ;)
- Melv.
03/14/2005 (12:56 pm)
You can definately have as many scenes and windows as you'd like. You can also have many windows viewing the same scene.Lots of lots of nice stuff to discover. Isn't that the mark of a fun engine? ;)
- Melv.
#9
I have the same problem.
I have a radar that I want to mount to the camera (if possible).
The camera follows a spaceship object, which can go in any direction.
If I mount the radar to the player, the radar will rotate around the player as the player rotates.
I want the radar to stay near the bottom of the screen at all times.
08/03/2005 (5:41 pm)
Did you ever find a solution for this?I have the same problem.
I have a radar that I want to mount to the camera (if possible).
The camera follows a spaceship object, which can go in any direction.
If I mount the radar to the player, the radar will rotate around the player as the player rotates.
I want the radar to stay near the bottom of the screen at all times.
#10
the solution was to mount something directly on top of the player ship,
then mount the radar to that.
08/03/2005 (5:47 pm)
Maybe I should have thought a bit before posting, the solution was to mount something directly on top of the player ship,
then mount the radar to that.
#11
08/03/2005 (7:17 pm)
Why not just use another scenegraph? No mounting involved, it just sits in the window, regardless of what happens in another scenegraph.
#12
08/03/2005 (8:13 pm)
Yup another scengraph and window over your game scenegraph and window works well, thats how I work my T2D Gui System
#13
Mounting a camera achieves the effect I'm after except for the rotation. The camera can't be rotated, so it can't follow the rotation of the sprite. So if my sprite rotates 90 degrees on the playfield, it rotates 90 degrees on my HUD, and I can't rotate the camera -90 degrees to compensate. Is there some way to achieve this effect without rotating the camera? Melv says that camera rotation is on the todo list, but not a high priority. Sadly for me, my entire HUD design depends on being able to display this sprite...
08/04/2005 (6:14 pm)
I'm trying to work out a way to have a sprite from my playing field appear on a HUD, but without rotating. In other words, the sprite rotates as it moves, along with other kinds of animations and effects, and I want to capture everything in the HUD but the rotation. My sprite should always be directed the same way, regardless of which way it's directed on the playfield.Mounting a camera achieves the effect I'm after except for the rotation. The camera can't be rotated, so it can't follow the rotation of the sprite. So if my sprite rotates 90 degrees on the playfield, it rotates 90 degrees on my HUD, and I can't rotate the camera -90 degrees to compensate. Is there some way to achieve this effect without rotating the camera? Melv says that camera rotation is on the todo list, but not a high priority. Sadly for me, my entire HUD design depends on being able to display this sprite...
#14
I can't think of any easy way of doing it without the requested camera rotation.
08/04/2005 (6:46 pm)
If I understand you correctly you don't want the sprite to rotate, so why rotate it? Not as convenient, I know, but you can rotate the other objects around. You did ask if there was some way ;^)I can't think of any easy way of doing it without the requested camera rotation.
#15
So I really do want the sprite to rotate in the primary view, just not in the HUD view.
08/04/2005 (8:46 pm)
I probably didn't explain myself well enough. Suppose you have a character in a maze, top down. When you move left, right, up and down, the sprite rotates to orient to the direction. The HUD camera is mounted to this sprite. The sprite rotates in the HUD view along with the main view. The HUD view is supposed to be focused on the character, and the maze should rotate around the character in the HUD, but not in the main view. So I really do want the sprite to rotate in the primary view, just not in the HUD view.
#16
I guess what still isn't necessarily clear to me is why you can't rotate just one of the sprites. You say you want the HUD sprite to have all the effects, etc., of the main sprite so I guess you are setting everything for both sprites?
If that is the case I would use objects, and a different one for each case. In the HUD case calling setRotation() would cause a rotation of the maze in the HUD, not the player sprite.
Again, I can see why camera rotation would be preferable, but it should at least be doable.
Or am I missing something again?
08/05/2005 (4:52 am)
If I follow correctly you are wanting two views: one in which the character rotates in the maze, the second in which the maze rotates around the character. I've seen arrangements like that in some games.I guess what still isn't necessarily clear to me is why you can't rotate just one of the sprites. You say you want the HUD sprite to have all the effects, etc., of the main sprite so I guess you are setting everything for both sprites?
If that is the case I would use objects, and a different one for each case. In the HUD case calling setRotation() would cause a rotation of the maze in the HUD, not the player sprite.
Again, I can see why camera rotation would be preferable, but it should at least be doable.
Or am I missing something again?
#17
Thanks for helping out.
08/05/2005 (12:54 pm)
What I was hoping to do was simply fix a camera on the object and not have to deal with having two seperate objects (and there are four of them, each with highly complex hierarchical mount structures). But without the ability to rotate a camera, I was forced to create a seperate set of objects for my HUD view. Now that it's in place, there are some advantages to doing it this way, so I'm happy with it.Thanks for helping out.
Torque Owner Tim Doty