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 / Having an object face the direction it's moving

Author
Message
Nameless
20
Years of Service
User Offline
Joined: 11th Apr 2004
Location: U.S.A.
Posted: 11th Jan 2005 08:49
For a while I was using a sphere as the main character for my game but when I switched it to an actual character model I ran into a problem. When I have my person move right I naturally want them to face right but the only way I can think of having them face right is to rotate them using the “rotate object” command. While this may seem simple it gets much harder when you have to find the angle that you should rotate it from every other direction. For example if the model was facing down and you wanted it to turn right then you would have to rotate at a different angle then you would if it was facing left and you wanted it to turn right. Basically I asking if anyone could give me some code that will face my model in the direction it’s going. Thanks
Major Payn
20
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Jan 2005 09:09 Edited at: 11th Jan 2005 09:10
Just use the rotate objec command untill you get the character facing the right way, then use the command...

set object pivot objnum

That command will lock the object to that rotation.





Hope that helps.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 11th Jan 2005 09:19
I am assuming you are using newxvalue and what not to come up with your new x,y,and z coords? If so why not just put something like

x# = newxvalue()
y# = newyvalue()
z# = newzvalue()

point object playerobj,x#,y#,z#
position object playerobj,x#,y#,z#

Nameless
20
Years of Service
User Offline
Joined: 11th Apr 2004
Location: U.S.A.
Posted: 12th Jan 2005 07:29
Quote: "set object pivot "


is that even a command?
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 12th Jan 2005 08:24 Edited at: 12th Jan 2005 08:28
Quote: "if the model was facing down and you wanted it to turn right then you would have to rotate at a different angle then you would if it was facing left and you wanted it to turn right."


That's not actually the case - the rotate object commands are absolute rotations using world coordinates - put simply, if you say yrotate object obnum,90 - it will always face to the right. It is the 'turn object' commands that are relative to the current orientation.

By the way, it's 'fix' object pivot.




Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Jan 2005 21:37
If your character is only moving in two dimensions, then its pretty simple.
if rightkey() then yrotate object 1, 90
if lefkey() then yrotate object 1, 270
if downkey() then yrotate object 1, 180
if uptkey() then yrotate object 1, 0

"eureka" - Archimedes

Login to post a reply

Server time is: 2024-09-23 09:24:54
Your offset time is: 2024-09-23 09:24:54