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 / Box at the front of a Player

Author
Message
Fane
14
Years of Service
User Offline
Joined: 9th May 2012
Location:
Posted: 8th Nov 2012 20:54
Hello,
i am programming with DBP for a few days. I have made a matrix and a box on the matrix. The player can walk through pushing wasd and look around with the mouse. My problem is that I want to make a box at the front of the player. If you look around with the mouse the box should be still at the front. But if I programming that the box is only rorating at the own axes. Is there a mathematical formula or something ?
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 8th Nov 2012 23:13
You can position the box at x,y,z of your player, and then move the box slightly in front of the player then yrotate the box the same angle as your player y angle.

position object my_box,object position x(player),object position y(player),object position z(player)
yrotate object my_box,object angle y(player):move object my_box,10


Cheers.

I'm not a grumpy grandpa
Fane
14
Years of Service
User Offline
Joined: 9th May 2012
Location:
Posted: 9th Nov 2012 10:47
Oh man I had the same code but without the move object line ....
thank you for your help it works great
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 9th Nov 2012 18:54
When you get more experienced, look into the help files for NewXValue, NewYValue & NewZValue commands. Obviously Chafari's code is all you need, but these more advanced solutions are an important stepping stone into handling situations that you will face in the future.

Login to post a reply

Server time is: 2026-07-10 12:35:27
Your offset time is: 2026-07-10 12:35:27