# 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 / Need Help! Using Mouse to move - can't look up/down just left right

Message
Posted: 24th Jul 2014 01:37
Greeting again!

I ran into a small issue on my program coding. I am doing very well merging "FPS Creator" created world with DBPro to make a quite interesting board/adventure game. I use the mouse to turn left and right and the mouse buttons to go forward or back. It was suggested to me why don't I fix it so I can have 360 degree view to look around. Well I made several attempts with various Mousemove and Point Camera commands but with very bad results. Stand alone I can do it outside the program but the program has some odd variables and commands that seems to contradict the code to look around all over. I would appreciate any input. Unmodified Code snippet attached.

When old programmers die...do they decompile?

#### Attachments

Posted: 24th Jul 2014 03:36 Edited at: 24th Jul 2014 03:39
Hi Katyman

I'm not sure if you meant to post more code. Anyway, I didn't see where you altered the X angle of the player. Without running it to check, it seems you could do something similar to what you did for the Y angle, like this:

EDIT: Bear in mind that you should limit the X rotation, so that you don't go too far. I would suggest you print the value of ax# on the screen each loop and write the code to limit the upper / lower values.

So many games to code.....so little time.
Posted: 24th Jul 2014 06:35

Ay# = Object Angle Y(Player)
Ay# = Wrapvalue(Ay# + (Mousemovex() * .13) )
Yrotate Object Player,Ay#
Ax# = Object Angle X(Player)
Ax# = Wrapvalue(Ax# + (Mousemovey() * .13) )
Xrotate Object Player,Ax#

Which on the surface looks correct. This was what I thought too. But the result is this: Camera remains looking straight ahead and POV starts to rise then flips instantly to view what is behind the camera. At no time does the POV look up or down. This is what is bothering me and the code I supplied is where movement occurs. I have over 10,000 lines of code, but this is the Function that checks the mouse movement, mouse clicks, and collisions. The "player" and "Camera (Camobj)" are two separate objects but linked. Maybe I am looking at the wrong object? Any suggestions?

When old programmers die...do they decompile?
Posted: 24th Jul 2014 11:02 Edited at: 25th Jul 2014 02:11
Okay, I have like two seconds before I have to get ready for work. I need a little time to put an example together to help with this. Basically, you would need to use newxvalue and newzvalue for the correct angles. I'll check with you later on this.

So many games to code.....so little time.
Posted: 25th Jul 2014 02:10
I took some of your code and wrote something that allows you to move around using the mouse. You can look up or down while moving forward or backward. I didn't take time to setup Sparky's - mainly just showing how you can rotate up and down. You'll notice that it can get a little goofy at times. This is why you need to code a limit (up and down) for the x angle. I have it printing on the screen so you can see it.

Hopefully, this is something along the line that you were looking for.

So many games to code.....so little time.
Posted: 25th Jul 2014 04:49
I will try it and get back with you and let you know how it worked out. Thank you for your assistance.

When old programmers die...do they decompile?
Posted: 29th Jul 2014 02:33
I ran the code you provided and that is what I am looking for. I extracted what was required within my program and I can look around just fine!! However as you mentioned the collision no longer works on anything not part of Universe.dbo like .X objects added within the program. Walk right through them. However anything that is part of the world (Universe.dbo) is solid.

This is as far as I was able to get before I had to stop and regroup my brains LOL! Sparky's can be a pain but if you see where I need to fix the collision, I would appreciate this. I will continue to work on it in the meantime and let you know if I can get it colliding again until I hear back from you. But it's nice to look up into the clouds now

When old programmers die...do they decompile?
Posted: 29th Jul 2014 02:35
Global AttackvalGlobal Ay# as Float

That was a typo on my part on the snippet, should read

Global Attackval
Global Ay# as Float

When old programmers die...do they decompile?
Posted: 29th Jul 2014 07:20
Forget to mention I need the gravity due to having steps and multilevel world.

So Here is where I stopped:

You had Player set at 1 whereas I have it at 6 so I made that change. Anyhow I look forward to your suggestions.

When old programmers die...do they decompile?
Posted: 29th Jul 2014 14:04
Hi, could you please include all of your code in one snippet? I tried piecing things together with what you have posted, but there is still some missing.

So many games to code.....so little time.
Posted: 29th Jul 2014 19:53
The code I have is over 10,000 lines and growing. I plan to clean it up and condense it. Since I plan to eventually sell it I can't give you the entire code but what I did was extract items that show the basic lines what check for collisions. I hope this will be enough. I have been working on the project for over a year now during my free time.

When old programmers die...do they decompile?
Posted: 29th Jul 2014 20:31
Wow, that is a lot of code. It appears that you may have a scaling issue. For objects that need to be scaled with Sparky's, you need to do the following:
1. setup the object in sparky's
2. use the command sc_AllowObjectScaling (object #)
3. scale the object
4. sc_UpdateObject (object #)

It seems like many of your objects are indeed scaled, so this might do the trick for you. Give it a try and let me know if you need anything else.

So many games to code.....so little time.
Posted: 29th Jul 2014 22:43
It will take a while but I will get back with you ASAP when I am finished. Lots of objects.

When old programmers die...do they decompile?
Posted: 30th Jul 2014 03:59
I completed adding the command sc_AllowObjectScaling (object #) to all the objects. I am testing the nearest one here:

And just below the Function MovePlayer is this:

So that part of the function looks like this now:

Still not getting a collision. I walk through the Door (Obj 40) but not through walls or go through floors within the "world" object (Universe.dbo).

When old programmers die...do they decompile?
Posted: 30th Jul 2014 04:55
I noticed that you are turning on and off the collision to object 40. One idea is to try it without turning it off at all just to see if that might be the problem.

Another idea is to use the command SC_DrawObjectBounds (object #) after you setup and update the object. This will show you what sparky's sees and what it is colliding against. You might be surprised, especially with animated models. Many times I will see the collision sphere / box / whatever significantly lower or in a different size or rotation than what I thought it would be.

Lastly, I would consider taking advantage of sparky's grouping capabilities. For example, I will group NPC's into a certain group number, moving objects into another (bullets could be in one group, platforms could be in another, for example), doors into another, etc. This way I can check for a group collision for that particular group only when needed. The advantage is that the less collision checking I have to do, the better. For the doors, you could even use a distance check to see if you are close and just forget about sparky's for that.

Anyway, I hope there is something here that helps.

So many games to code.....so little time.
Posted: 30th Jul 2014 15:24
Well I was able to make it work finally. The command SC_DrawObjectBounds showed I was using the wrong collision type but what puzzles me is why it worked before. I had sc_Setupobject 41,1,1 for the doors and items and it worked before the change and stopped afterwards. When I changed it collision type to "0" then it became solid again. I will need to make adjustments but if I have more problems I will let you know. Thank you for your assistance.

When old programmers die...do they decompile?