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.

AppGameKit Classic Chat / Making an object always stay on the same position and rotation on the camera (First person objects).

Author
Message
SmileSlime
7
Years of Service
User Offline
Joined: 10th May 2017
Location:
Posted: 1st Nov 2017 04:06
I want to have my first-person game to show a 3D object that stays in the same position and rotation on the screen. Like a sword that the player holds. I've tried to do this but most of the time the object would rotate too far away from the camera, making it look weird.

I don't really know if I worded this right, but I'd like to know how I can do this.
I love games, who doesn't?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Nov 2017 11:45
i think you can set the same position as the camera, then rotate same as camera, then
RotateObjectLocal & MoveObjectLocal in front of camera
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.9.3) Radeon R7 265 : Mac mini OS High Sierra (10.13)
SmileSlime
7
Years of Service
User Offline
Joined: 10th May 2017
Location:
Posted: 1st Nov 2017 16:51
Quote: "i think you can set the same position as the camera, then rotate same as camera, then
RotateObjectLocal & MoveObjectLocal in front of camera"


That doesn't sound that clear to me. I tried what you said but it doesn't seem to work.
I hope someone comes up with an example.
I love games, who doesn't?
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 1st Nov 2017 17:12 Edited at: 1st Nov 2017 17:22
This may help you.




I also think, that you need some sort of depth control, so your gun always stays infront of the walls of your level.
Just go though each 3d command in the code reference, the description will tell what they can.
I think setobjectdepth() will be enough for this task.
The next think would be to replace crx#, cry#, crz# with a curveangle function value, so the gun would smoothly rotate with the camera.


The most elegant way would be a shader for the camera fix, as it saves the most ressources and keeps your code clean from visual operations.
But the AppGameKit solution will help you better to understand how it works.

[/url]
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 1st Nov 2017 17:46
example from me
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.9.3) Radeon R7 265 : Mac mini OS High Sierra (10.13)
SmileSlime
7
Years of Service
User Offline
Joined: 10th May 2017
Location:
Posted: 1st Nov 2017 19:32
Quote: "This may help you."


Quote: "example from me"


Thank you both, I will try to integrate these into my projects.
I love games, who doesn't?

Login to post a reply

Server time is: 2024-11-24 08:31:46
Your offset time is: 2024-11-24 08:31:46