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.

DarkBASIC Professional Discussion / Getting player to move in camera's direction

Author
Message
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 19th Dec 2010 02:45
Hello all, how do i get the player to move in the direction the camera is pointing?? I want my camera to be rotated by mousemovex(), and that all works fine, but i want that to change the direction the player rolls as well


All help appreciated!

Thanks

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 19th Dec 2010 03:00
Instead of directly controlling the camera. Try controlling the player object instead, and getting the camera to follow it's angle, with either set camera to follow, or using alternate code if preferred. If you want say up and down movement with the camera using mouse simply add it to the angle camera only, and obviously not the object, unless you want that to rotate up and down as well.

http://s6.bitefight.org/c.php?uid=103081
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 19th Dec 2010 03:36
I would do that, but im trying to figure out how to determine the players direction by how much youve turned, if you know what i mean. Also, what command might you use to make the object go a certain angle?

Thanks dvader xD

C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 19th Dec 2010 11:05
@ Dark basic dude79
Can you not just do something like:
rotate object obj,0,camera angle y(0),0

Or if it's using a physics engine can't you just rotate the sphere by the same amount the camera is rotating around? (mousemovex())

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 19th Dec 2010 15:15
There are lots of methods for camera control, what are you after exactly? Are there any games out there that demonstrate the type of camera motion you want?
If you want the camera to have a smooth following effect, change the smooth value of set camera to follow or use the curveangle() command if doing it manually.

http://s6.bitefight.org/c.php?uid=103081
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 19th Dec 2010 19:28 Edited at: 19th Dec 2010 19:35
Well, in the main loop, i use position object x,y,z, so im not sure how i would calculate what those coordinates would be. hope that makes more sense. What im referencing to is Cowboxes awesome soup xD You move the mouse, it rotates around the player, and changes player direction as well




I have also been having other probs with the cam. When i follow an object after i added a skysphere, the camera does move, but i cant see the object im following..

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 21st Dec 2010 18:32
The easiest method that will probably help you is one I use quite often. Position your camera at the co-ords of the object you wish to follow. Rotate as needed. Then move the camera away from the object the distance you wish to view from. Do all that at once before your sync so all you can see is the camera positioned behind the object. Regarding how you rotate really depends on what type of game it is. In my current marble mania project for instance I use Dark Physics, and so it is easier to have a set non rotating view, as then the x,z axis never alters and make it a lot simpler control wise. Are you using physics or just standard DB?

http://s6.bitefight.org/c.php?uid=103081
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 21st Dec 2010 23:43
i see I use standard dbpro

Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 22nd Dec 2010 00:12

Note: Just wrote this up, don't know if it actually works.

This code creates a cube, and tasks the camera to follow this cube where ever it goes with the cube's rotation changing every 10 seconds.

The commands newxvalue, newyvalue, and newzvalue all calculate three dimensional movement along a y-angle insteading of making you use trig.Does this answer your question?


Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 22nd Dec 2010 00:28
It doesnt seem to work... But thanks! Ok, it doesnt seem like im being clear enough. I want something that would for example allow you to rotate the cube, and it would go forwards in the direction it's pointed, like a car would. I want a formula or similar that would allow me to get the xyz coordinates depending on the angle. Thanks guys!

Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 22nd Dec 2010 00:33
Quote: "The commands newxvalue, newyvalue, and newzvalue all calculate three dimensional movement along a y-angle"


Usage:



Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 22nd Dec 2010 00:55 Edited at: 22nd Dec 2010 00:56
Thanks!! That is EXACTLY what i was looking for

Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 22nd Dec 2010 01:20
never mind, it wont work. i want the dot to move diagonally.



PLEASE help people!

Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 22nd Dec 2010 01:58
Quote: "Quote: "The commands newxvalue, newyvalue, and newzvalue all calculate three dimensional movement along a y-angle""

They're for three dimensional movement only. Did you read my post at all? I thought you wanted a cube to move along an angle in 3D space? The dot command is two dimensional not three dimensional.


29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 22nd Dec 2010 02:16 Edited at: 22nd Dec 2010 02:17
Hi, thought I might add my 2 pence worth here.

@Dark basic dude79

Your last bit of code does work but the dot starts in the top left of the screen and moves off diagnolly upward and to the right.

Change the starting value of y# to 300 and you'll see a diagnol line being drawn (i.e. multiple dots as you're not deleting the previous dots).

However, I wouldn't use the newxvalue and newyvalue commands in 2D, as far as I know they're designed to be used within the 3D evironment coordinate system (but someone else may know more than me on this).

Back to your original dilema regading camera position and such, I'm having a bit of trouble understanding what you want.

Are you looking for a type of 3rd person camera view, whereby you control an object and the camera follows it?





Or are you wanting to point the camera in a particular direction and move an object out in the direction the camera is pointing, but the camera itself doesn't move?




I've used the method DVader described for positioning the camera.

Hope one of these helps.

I've just reread through the posts and I think you want the first code snippet but I'll leave the second snippet now I've written it.
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 22nd Dec 2010 03:27 Edited at: 22nd Dec 2010 03:37
@dar13 OK, OK! Yes i did read, i was irritated that things werent working so i dint feel like making a cube so i was experimenting thinking that 2d would work as well I just didnt understand the what you were saying the best. Thank you for your posts and quick replies though

@29 games Yes, the first one is precisely what i want, thanks for writing it and the other one!

I apologize to anyone that was confuzzled by me not explaining what i want clearly enough






Edit:

Arrrg, im sorry that didnt work the way i wanted either. Im sorry im being so picky guys, ill post a code snippet to maybe help you guys see what i want...





this is why i think newxvalue and the other 2 (x and y) are important.

29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 22nd Dec 2010 04:00
Hold on, I think I've got this:




Is this what you mean?
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 22nd Dec 2010 06:34
... Im sorry, but no... I feel bad because you go to the work to this and it's not what i wanted, so thank you An example is soup by cowbox, that's what im after. You move the mouse left or right, it turns the player, and the camera (although the camera still is looking directly at the player) and that is the direction the player moves. I still need to use pos obj command though. We need cowbox, he knows, lol!! But take a little try at soup (small and free http://forum.thegamecreators.com/?m=forum_view&t=168311&b=5) to see what i mean Thanks man

C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 22nd Dec 2010 07:17 Edited at: 22nd Dec 2010 07:28
xD Sounds like it's up to me to save the day here.


There you go Db dude..... the mechanics in that code are basically just ripped straight from Soup but are missing things like camera collision and various other fancy things just to keep it simple.

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 22nd Dec 2010 15:48
Looks like Cowbox has sorted you out. It is a lot easier to get the cam following if you are only using standard DB commands as you can actually set the objects angle in your code Dark Physics basically takes over object control so you can't do it directly. I haven't played soup so no idea what camera view it has.

http://s6.bitefight.org/c.php?uid=103081
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 22nd Dec 2010 23:31 Edited at: 22nd Dec 2010 23:41
Yes, tis fun. Thanks cowbox, that should help! Again that doesnt use pos obj xyz command, so to get around that, how do you jump and allow for sliding collision? The way ive learned says i need pos obj... It feels like im missing some vital knowledge here, lol! Thanks cowbox


Oh yah, i saw the commenting and no i dont get the trigonometry... We havent learned in school yet, lol!

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 23rd Dec 2010 11:03
Try the 'Set Camera To Follow' command.

You use MouseMoveX To rotate the cube, then give the cubes Y angle to the follow command and voila.

My signature is NOT a moderator plaything! Stop changing it!
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 23rd Dec 2010 17:18
Yes, i know how do do that... It's that I need to know how to calculate the x, y, and z coordinates depending on the objects angle. The way C0wbox moves his camera is exactly what i want because he uses angles to calculate the new xyz coordinates for that camera. But thanks Mobiius

29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 24th Dec 2010 02:29
Quote: "I feel bad because you go to the work to this and it's not what i wanted"


@Dark basic dude79, it's not a problem.

I've modified C0wbox's code.

Instead of the move object cammand, I've used the newxvalue and newzvalue to determine the coordinates of the player (line 30) and I've also added some jumping code just to show you how it could be done (line 37). The player object is then position using the position object command (line 47). I've also separated the camera coodinates out into their own variables (x_cam#, y_cam#, z_cam#) (line 49). I've copied and pasted the maths that C0wbox used (but I've lowered the camera down a bit to better show off the jumping).

Press space to jump.



You should be able to do the collision from here.
Dark Java Dude 64
Community Leader
15
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 24th Dec 2010 05:17
Thanks!! This is exactly what i want, and i say that after looking through the code as well Thanks man!

Login to post a reply

Server time is: 2026-07-21 20:34:50
Your offset time is: 2026-07-21 20:34:50