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 / Rotate and bank at the same time?

Author
Message
IvorySquirrel
13
Years of Service
User Offline
Joined: 9th Apr 2011
Location:
Posted: 10th Apr 2011 03:56
Hi, I'm making a 3D Asteroids game, top-down view, and I would like the player space ship model to "bank" a few degrees left or right, depending on which way you are turning. I'm fairly new to the DBPro language, and from what I can tell, there is no way to rotate an object TO a specified angle along its own axis, only using global axises, or adding on relative to its current ones. Here is some code I tried:
This does not work how I would like it to however, it seems to work for the top 180 degrees of turning, but then it freezes when facing right and left, and turns the wrong way when I press the button again.. Can someone explain why this is happening, or tell me a way to make it work properly?

Also, I'm not very familiar with the syntax yet.. if there is a way to make that code more efficient, let me know.

Thanks
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Apr 2011 18:09
This may depend on how your object is set up, but you can try it and see if it works for you - I find that banking looks and works fine if you carry out your x and y rotations on the whole object, and apply your z rotations on limb 0.

The requirement of the object is that all other limbs except for limb 0 must be children of another limb, or of limb 0.

If you have my plug-ins installed (they're free!), then you can compile this code I wrote a while back as a trial:


It needs my plug-ins for the construction of the players ship.

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 10th Apr 2011 19:58
SET NEW LIMB COLOR does not compile and is not highlighted as a command in the editor, nor does it appear in the help files for collection 18.

Is it new and I don't have the update?

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Apr 2011 21:28
My apologies for that - that's a new addition that will be in the next release (which I'll hopefully upload fairly soon).

Just comment out the lines with that command.

IvorySquirrel
13
Years of Service
User Offline
Joined: 9th Apr 2011
Location:
Posted: 10th Apr 2011 23:52
My ship object is very simple, and doesn't have limbs.. just a basic model file. Will this still work?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Apr 2011 12:55
Yes. All objects have a limb zero...

By rotating limb zero you don't affect the 'actual' direction the object is pointing.

IvorySquirrel
13
Years of Service
User Offline
Joined: 9th Apr 2011
Location:
Posted: 20th Apr 2011 01:25
Thank you, it works perfectly. Now, another question along the same lines.. I would like my ship to rotate and move separately.. as in the original "Asteroids" game. The only function I can find is "move object" to move an object, but that is not an option. So I tried using some trig to move my object based on a speed variable.. once I find out how it works I will figure out how to add motion in a direction, etc, but my code doesn't work. I tried something along the lines of this (don't have the actual code at home):

It seems to move a very slight amount in the correct direction from the center of the screen, even though I have added on the previous position.

Login to post a reply

Server time is: 2024-11-24 04:26:24
Your offset time is: 2024-11-24 04:26:24