Game Development Community

dev|Pro Game Development Curriculum

Free-rotating Player with quaternions

by Daniel Buckmaster · 01/17/2009 (7:25 am) · 12 comments

Okay, why did my resource appear as a blog?

This resource adds the ability for Players to rotate freely using quaternions. The behaviour of the default player is not changed; you must extend Player to use the free rotation capability for your specific needs. Note: This resource breaks the AIPlayer thinking logic. I'm working on an updated getAIMove function to take my changes into account.

As soon as I figure out how to post this as a resource, I will. I'm taking out all the code changes for now, since I think blogs are public.

A feature I've long wanted is the ability for Players to rotate freely, for effects such as walking around planets in Super Mario Galaxy, or running on the walls and ceilings in AvP. There is an old resource for his, but as far as I can tell, it doesn't work very well (if at all) with 1.5.2 or the network. So here's my shot at it.

This resource adds the ability for Players to rotate freely using quaternions. The behaviour of the default player is not changed; you must extend Player to use the free rotation capability for your specific needs. This might be aligning the Player to the terrain or other objects, rotate based on move input (if your Player is flying or swimming) or whatever other wackiness you want.

Here's a quick overview of my changes. Basically, we add an 'orient' member to Player, which stores a quaternion with the Player's current orientation. We also need delta quternions for handling interpolation and the like. Whenever in the past we've set the Player's mRot value, we now compose a quaternion rotation and apply it to our orientation. The orientation is sent over the network, so this resource *should* work for multiplayer. Like I said, not yet tested. We use our orient quaternion to create transform matrices whenever we need to, and to orient vectors and boxes correctly.

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
01/17/2009 (7:29 am)
Can someone enlighten me? :P
#2
01/17/2009 (7:34 am)
Hmmm perhaps a bug in the new site.. I see on the page where you create the resource there isn't an upload feature either to attach code to the resource :(

Think it's another one to add to the list of features to resolve
#3
01/17/2009 (8:34 am)
@Daniel, If you like I could host the file on my site till GG gets the resource files figured out.
Just send me an e-mail with the zip and I'll post a link here for you.
#4
01/17/2009 (9:35 am)
Thanks for the offer, Bill! I might take you up on that if I can get the actual resource posted. At the moment, I don't want to post it as a blog, since it contains a bunch of code, and I think blogs are public. Resources, if I'm correct, are private... or am I way off base?
#5
01/17/2009 (11:10 am)
@Daniel: as I recall from the old site Blogs and Resources were both public, only certain Forum Threads were ever private. I know I was able to view the resources long before I ever held an account here.
#6
01/17/2009 (12:22 pm)
Huh... okay. Interesting. I just checked as well and all the resources are public. I assumed GG didn't want any source code getting out. Maybe it's OK for the relatively small amount in resources.
I still want to know why this is a blog, though, not a resource :P.
#7
01/17/2009 (2:38 pm)
silentMike, all resources were not public. I remember a lot of the time being unable to view certain tgb resources, or back when there was the glitch of TGE 1.5.2 users being unable to view TGE 1.4 and TGE 1.3 resources. Most resources are public, but I know there is a way to set them as private for owners of a certain engine.
#8
01/17/2009 (4:53 pm)
AIPlayer not working is a simple fix, if I remember correctly. I think Martin Schultz did some work on AIWheeledVehicle, and that's where I got the code from that calculated offset for turns. I suppose that's what you were looking for. Nice work!
#9
01/17/2009 (7:22 pm)
resources are public i can see them just fine. i do think some are limited though to where i cant see but i have not found a person that i clicked on to where i cant see that resource. i getting the engine soon anyway so it will not mater anyway.
#10
01/18/2009 (6:58 am)
Okay, I'm posting it on the TGE private forum for now:
www.garagegames.com/community/forums/viewthread/82893
#11
01/19/2009 (5:09 pm)
Would you mind posting this on TGEA private forum, as well? The new site layout currently isn't allowing me to view that forum thread, even though I think I should be allowed (I have TGE).
#12
01/31/2009 (1:29 am)
And... it's now a resource. I guess that will solve the problem ;)