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 / Lock object on

Author
Message
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 24th Aug 2004 15:52
I'm having problems with lock object on. Basically, I have an object positioned infront of the camera where I want it on the screen (it's a HUD made out of a ghosted box). When I have lock object on, though, the object just disappears. Can somebody explain how this command works? Thx.


Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 24th Aug 2004 19:47 Edited at: 24th Aug 2004 19:52
I had the same problem, in my case I wanted a screen overlay, but when I locked the object to the screen it disapeared, so I gave up and used this instead (and before anyone posts, I had the minimum camera range at 0.001 and the plain 2 units ahead of me and it still didnt show when locked)

(object 1 is the plain in this example)

position object 1,camera position(x),camera position(y),camera position(z)
set object to camera orientation 1
move object 1,2

and did this every loop, it didn`t affect the framerate (ie it made less than 1fps difference) so it`s an acceptable workaround.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster.
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Aug 2004 00:02
Thanks Mentor - I played around with that, but it got pretty tricky. I need the object slightly infront of the camera - so I'd need to work out some geometrical expressions to move the object in a circle around the camera when the camera rotates.

Could be done, but if anyone knows why lock object on isn't working that would save me doing the maths......


Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 25th Aug 2004 00:05 Edited at: 25th Aug 2004 00:06
you wouldn't need to do anything to make it work when you rotate the camera...

that example should work fine. just run it every loop(or every time you move/rotate the camera)

"We make the worst games in the universe."
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Aug 2004 01:08
Quote: "you wouldn't need to do anything to make it work when you rotate the camera..."


Even if it's offset from the camera? I'm not convinced. If I want it say 50 units infront of the camera, how do I do that with that code? you can't just say



because, although it rotates to point in the right direction, it doesn't stay infront of the camera. That's why I think you need to tell it to move around the camera as well as rotating on its own axis.

I don't understand why the 'move object' command is there either - surely the 'position object' command is taking care of the object's movement?

This would be easier if I could get the lock object command to work - anybody....?


Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 25th Aug 2004 01:56
Problem solved. Lock object makes the objects position coordinates relative to the camera. So you need to change the objects position from what it was in real space coordinates, to something like 0,0,20 - regardless of where the camera is positioned, to get it 20 units in front of the camera. Now why didn't I know that??????!!!!!


Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 25th Aug 2004 22:05
wierd...

Quote: "Even if it's offset from the camera? I'm not convinced. If I want it say 50 units infront of the camera, how do I do that with that code? you can't just say

+ Code Snippet
position object 1,camera position(x),camera position(y),camera position(z)+50
"


your right but you don't just do that one command you do this...
which puts it at the camera...


which point it in the same direction as the camera(so now it's right on top of the camera pointing in the same direction)


which moves it two units the direction the camera is facing(essentially putting it 2 untis infront of the camera)

you could change the 2 units to whatever you want...

"We make the worst games in the universe."
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 26th Aug 2004 20:47
I see - rotate then offset, rather than offset then rotate. Makes sense. Thanks Peter - that's useful to know.


Login to post a reply

Server time is: 2024-09-22 22:17:32
Your offset time is: 2024-09-22 22:17:32