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 Discussion / Attaching Mouselook to objects

Author
Message
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 15th Feb 2009 20:47
Yes how do I attach an object to mouselook code so I can use it as a 1st person player object
?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Feb 2009 21:57 Edited at: 15th Feb 2009 21:59
Well, there are a few ways. Did you try lock object on? That'll lock the object to the camera:



Another way is to use the camera movement code for the object and then use Set camera to follow:



There are other ways too. But these should get you started.

Enjoy your day.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 16th Feb 2009 12:00 Edited at: 16th Feb 2009 12:09
Thank you latch but I also wanted to have it in the 1st person as well as the 3rd person option
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Feb 2009 21:58
OOOPS! Sorry, I didn't read your post carefully! In these examples just back up the cube - basically putting the camera at the eye level of the character for 1st person. Play with the distance values a little and also the set camera to follow code to get it to look how you want. This is the same as example as number 2 above except you can press the spacekey to switch between 1st and 3rd.




Enjoy your day.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 17th Feb 2009 00:22
thanks Latch
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 17th Feb 2009 11:16
trying to get it to look up and down as well , I was thinking I would possibly only be able to do this with head and arms?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 18th Feb 2009 01:02 Edited at: 18th Feb 2009 01:05
The whole trick is to position the character somewhere then positioning the camera at the character's location. If you want the camera at the character's arm, or it's head, then you'll have to adjust the height and the position of the camera accordingly. If you use SET CAMERA TO OBJECT ORIENTATION, then the camera will be facing the direction of the whole character. If you want the camera to rotate based on head movement at that point, then you'll have to query the limb rotations so it might look something like:



Enjoy your day.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 18th Feb 2009 06:28
Thanks Latch and yes I thought it would be something like that, and would have to co inside with arms as well as would be either holding a weapon or grabbing something from above or pushing something or punching something from above, also have to tilt their back as well
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 18th Feb 2009 13:33
hi Latch tried the head moving code with a model but can't get it to work for some reason pity you can't have commands like pitch limb up, or pitch limb down then things would work easliy I think

arbiter chewbacca hybrid
16
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 18th Feb 2009 19:40
Latch do you mind if I borrow some of that code for my game
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Feb 2009 01:45
@vampyre

This doesn't seem quite right:

What's 17x and 17y?

Also the head code is based on rotating the camera based on the current head position. It would probably be better to rotate the head then pick up the rotation for the camera. the example I posted doesn't do that exactly. Should be more like:



@hybrid
no problem

Enjoy your day.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 22nd Feb 2009 13:10
17 was her head as that is the limb number but it ddin't work Latch
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Feb 2009 02:26
I don't see where 17x, 17y or 17height are defined anywhere.

I knocked together a complete example. Press space to toggle the mode. When in 1st person mode, hold the right click button to look around with the head, otherwise, the mouse move will sterr the whole character.



Enjoy your day.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 26th Feb 2009 03:51
Thank you Latch sorry for the late post I will look at it
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 1st Mar 2009 04:15 Edited at: 1st Mar 2009 04:16
had a look at it and it is great Latch but is there anyway you could do it without having to hold down the right click mouse button please? It 's just I have been trying to get it to work with this babe model
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 2nd Mar 2009 01:19
Because I was using the mouse to steer the whole object and to turn just the head, I had to have a way of differentiating between what I wanted to do using the same control. So I used the While mousclick()=2 etc.

If you want to steer, and move the head, either ue a mthod similar - while a certain event (like a mouseclick) takes place, steer or move head. Or, setup two controls. One for steering, and the other for head movement. You could control the steering of the character with the arrow keys perhaps, and you could control the turning of the head with the mouse look.

It's possible to steer the object and turn the head with the same control, but you'd have to manage how far the head turns before the whole body follows the rotation.



And to make the body smoothly turn to follow the head instead of snapping to the rotation, use CURVEANGLE .

Enjoy your day.
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 4th Mar 2009 11:30
OK Thanks Latch

Login to post a reply

Server time is: 2025-06-08 02:23:43
Your offset time is: 2025-06-08 02:23:43