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 / Player rotation problem

Author
Message
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Aug 2008 22:09 Edited at: 14th Aug 2008 22:11
Hey guys!

As you may know, I am working on a Kirby game(3d), and right now, he jumps, does a triple jump, a long jump, a back-flip, a butt-slam, wall-kicks etc.

Anyway, a problem has occurred with stearing the player. I made it so the player rotates according to the input:

up arrow is 0°, right is 90°, down is 180°, left is 270°
up+right is 45°, right+down is 135°, down+left is 225°, left+up is 315°

if I push up, and then left, the player will rotate from 0° to 270°, making the player turn 270° instead of 90°, which is of course unusual. And I don`t know how to make it rotate the shortest distance. Can someone please help me?

Here is some quick code I copied and pasted(Don`t complain about all of the unused variables):



Controls are:
up, left, right down to steer player
delete to turn camera left
page down to turn camera right

Many Thanks in advance, TheComet

Suicide is away of telling God, You can’t fire me I quit !!!!!
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 14th Aug 2008 22:25 Edited at: 14th Aug 2008 22:45
Haven't tested it yet, but to make it the shortest direction, you can use 0,90,180 and -90.
[Edited it]
Nope that doesn't work with yrotate. The only thing I can think of is to use the turn object right/left, though I seem to remember that that method doesn't always work as well and you would have to redo your motion controls.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 15th Aug 2008 11:03 Edited at: 15th Aug 2008 11:40
I think what you need to do is to find the shortest distance using math (google it). And write your own curvevalue() function.

[EDIT]

Here's the function



The speed is how much it changes by. The lower it is, the faster it changes.


On the other hand, you have different fingers.
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 17th Aug 2008 23:37
Well...Did it work?


On the other hand, you have different fingers.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 18th Aug 2008 18:08
@NanoGamez Guy

I thought I posted an answer already, but it didn`t post...

It was a great Idea, and I actually started to use your function(with some minor adjustments, it didn`t work at the start), but then I some how typed "curveangle" instead of "Nanocurveangle" and it worked!

I was using "curvevalue". And that didn`t work, but "curveangle" did.

Anyway, thanks for the example, and thanks to my luck, I typed the wrong thing...

Suicide is away of telling God, You can’t fire me I quit !!!!!

Login to post a reply

Server time is: 2025-06-07 06:53:35
Your offset time is: 2025-06-07 06:53:35