Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Looking Up

Author
Message
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 11th Jul 2010 18:58
I've been able to get my joystick to control my character in a 3D environment. I started working off of the "Huge Dungeon" tutorial. I set the left joystick to move forward and straf left and right. I have my right joystick to rotate left and right. The last thing I'm trying to do is make my right joystick look up and down, not actualy rotate. That way, when I move forward, I still move along the floor or ceiling and not move toward it. Is there an easy command to do this?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 12th Jul 2010 06:12
Okay, this is something that I literally threw together in a hurry. It should show you how to make the camera scroll up and down without actually moving the camera up or down. I couldn't get my joystick twist to work on anything but the Z axis, so I wrote it using the arrow keys instead, but you can easily plug the joystick commands in.

So, it places a box on top of a larger green box so that you can get a perspective on things. You move the up / down arrow keys to tilt the camera up and down. Pressing the left/right arrow keys rotates the camera in that direction. Pressing the LMB will move you forward and pressing the RMB will move you back. Spacekey exits.



Hope this helps you,

LB


badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 13th Jul 2010 21:04
Actually, it did help a lot. The more I play around with it and see other people's examples, the more I realize that it is... well... rather "basic".
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 15th Jul 2010 05:03
So, the example helped, but now I have my next problem. I'm trying to use the left joystick to straf the camera left and right. I got the following code from another user. It was working, but with your method of looking up and down and moving forward, it doesn't work. How can I modify it so it works with your code?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 15th Jul 2010 18:02
The up/down action is done by looking at the joystick y axis, not the x axis (it is confusing because you are rotating on the x axis). Anyway, this should use the left stick on the joystick to strafe when moved. I didn't know the value of maxcubes, so I plugged in 100 and it seemed to work okay. I didn't know how you wanted to move forward/backward, so it still uses the mouse buttons.



LB

So many games to code.......so little time.
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 16th Jul 2010 04:11
We're getting close, but I am losing my direction somewhere. I believe I narrowed it down to the y rotate. I modified your code to help demonstrate.



Use the WASD keys to move forward and backward and straf left and right. Use the left and right keys to rotate on the Y axis. This all works good for awhile, but it then seems to break. To reproduce, use the keys to move up to the box, and straf around it. At some point when you are behind it, the keys take on a different angle or something. Seems to go from positive to negative? Something weird is going on.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Jul 2010 18:37
Okay, that was a tricky one, but I think I have gotten it ironed out. Check this out:



LB

So many games to code.......so little time.
badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 17th Jul 2010 17:44
Yes, this works much better. Thanks for all your help. I see now how much more important it is to work with the camera angles.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Jul 2010 18:44 Edited at: 17th Jul 2010 18:45
You're welcome.

The turn camera commands can be a little difficult to work with and I usually end up writing something myself instead of using them.

Good luck on your project.

So many games to code.......so little time.

Login to post a reply

Server time is: 2024-11-24 13:41:37
Your offset time is: 2024-11-24 13:41:37