Trying to Create a 3D Side Scroller
by Derek Coleman · in Torque 3D Professional · 05/11/2010 (8:11 am) · 5 replies
I am new to Torque 3D and it seems like their isn't documentation on everything yet so I was hoping someone might know a little more than me to help out.
The first thing I have been playing around with is trying to get the camera on the side of the player so it can track the player as you control the player. I have looked at the camera references but some of the different camera types in the tutorial are for an AI player and I cannot seem to control the player after I switch to a different camera mode. One thing I have tried is rendering the player facing the right or left but when I try to fire my gun it still wants to shoot forward and not in the direction the player is facing.
The next thing that I would like to figure out after this is to have a cursor on the screen that the player will fire towards. I played around with the RTS tutorial and have been able to get the mouse cursor on the screen but I am not sure how to get the weapon to shoot where the player clicks at and like the previous problem I still want to control the player with that cursor on the screen.
If anyone has any help that would be great!
The first thing I have been playing around with is trying to get the camera on the side of the player so it can track the player as you control the player. I have looked at the camera references but some of the different camera types in the tutorial are for an AI player and I cannot seem to control the player after I switch to a different camera mode. One thing I have tried is rendering the player facing the right or left but when I try to fire my gun it still wants to shoot forward and not in the direction the player is facing.
The next thing that I would like to figure out after this is to have a cursor on the screen that the player will fire towards. I played around with the RTS tutorial and have been able to get the mouse cursor on the screen but I am not sure how to get the weapon to shoot where the player clicks at and like the previous problem I still want to control the player with that cursor on the screen.
If anyone has any help that would be great!
#2
Would anybody know where to start with having the cursor on the screen and having the player fire in it's location. The best I was able to get is being able to bring up the cursor on the screen but I lose control of the player and I wouldn't know where to start with the shooting mechanic.
05/11/2010 (10:03 am)
This was a great start for my camera problems and I am going to keep playing with it to see if it will work. It would have been nicer if the camera didn't lock onto the player and only followed the player down a preset path but I will try to make this work for now.Would anybody know where to start with having the cursor on the screen and having the player fire in it's location. The best I was able to get is being able to bring up the cursor on the screen but I lose control of the player and I wouldn't know where to start with the shooting mechanic.
#3
Regarding the rest of your question:
The cursor/crosshair on the screen; Sean Rice did a nice port(s) here: http://www.torquepowered.com/community/resources/view/19509
Another thought, if you read close the RTS scripting tutorial, it gives you most of what you need to accomplish the point and shoot with the mouse.
In your spawnSphere for your player, change it to spawn an AIPlayer. Allow the mouse click to call a server fuction that passes the position of your mouse to be the aimAt location for the AIPlayer, then just setImageTrigger(true, 0); and then false to stop shooting.
After thought: Might have to take into effect the vector of the raycast from the mouse's position(maybe just the distance if we can get the camera to work correctly), in relation to the axis you are on; for a sidescroller to work that is, or you'll be shooting out into nowhere!
Also, the setAimObject method might be the way to go for a constantly updated "face the cursor"; but relaying the cursors position as an "object"...i've got no clue...I think TGB has a way of doing this.
HTH
05/11/2010 (10:57 am)
Daniel's link to our discussion about 3D side scroller is all I've come up with for now. Working on some other possibilities, but until GG gets a handle on it or you want to change a bunch of code with ports and old resources...which seems like a step backwards; we are stuck as is.Regarding the rest of your question:
The cursor/crosshair on the screen; Sean Rice did a nice port(s) here: http://www.torquepowered.com/community/resources/view/19509
Another thought, if you read close the RTS scripting tutorial, it gives you most of what you need to accomplish the point and shoot with the mouse.
In your spawnSphere for your player, change it to spawn an AIPlayer. Allow the mouse click to call a server fuction that passes the position of your mouse to be the aimAt location for the AIPlayer, then just setImageTrigger(true, 0); and then false to stop shooting.
After thought: Might have to take into effect the vector of the raycast from the mouse's position(maybe just the distance if we can get the camera to work correctly), in relation to the axis you are on; for a sidescroller to work that is, or you'll be shooting out into nowhere!
Also, the setAimObject method might be the way to go for a constantly updated "face the cursor"; but relaying the cursors position as an "object"...i've got no clue...I think TGB has a way of doing this.
HTH
#4
That resource for the cursor/crosshair seems overwhelming and I am going to have to spend a lot of time trying to break that down into what I need for my game. For now I am going to tinker around with some of the code and see what I can come up with and let you know if it works or not.
05/11/2010 (12:35 pm)
Those last few lines of the side scroller camera resource did the trick, it was what I was playing with earlier but I didn't realize I had to set the camera object as well. There seems like there is something wrong with my game because when I try to change the setup of the camera's position and rotation nothing happens. I have been able to work around this and I am just happy that I have a camera that follows the player when I control it.That resource for the cursor/crosshair seems overwhelming and I am going to have to spend a lot of time trying to break that down into what I need for my game. For now I am going to tinker around with some of the code and see what I can come up with and let you know if it works or not.
#5
05/11/2010 (2:52 pm)
The OrbitMode doesn't work like it's supposed to.
Torque 3D Owner Daniel Balmert
Default Studio Name