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 / Point object to position in space corruption/problems

Author
Message
BLink
22
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 13th Jun 2006 22:00 Edited at: 27th Jun 2006 23:58
::UPDATE, HERE'S THE SOURCE CODE:: controls are mouse to aim and left click to u-turn



I've always had this problem with making an object point at a position behind it, but I just can't figure out a way to make it work this time.

So, I've got an on rails game( moves you straight forwards while you aim the gun on a 2d plain) which has the ability to face backwards( in case you passed an enemy, you can still shoot them down before they get you). I have it set up so that object position 1 x and y = mouse position x and y -320 and -240 respectively. This makes it so that it goes to the farthest corner when your mouse is at position 0,0, and the default start position for the mouse is( obviously) 320, 240, making the default starting position for object 1 be 0,0,400.

As shown above, I have object 1 automatically Z positioned at 400, and when you press the turn around button, it goes through a fancy animation and ultimately your gun's rotation angles are 0,180, and 0, with object 1 being on a new set of commands. This command set has it's Z position be -400, it's X is -1*(mouse x - 320) and it's Y is (mouse Y - 240). It makes sure to correct the object angle so that it's pointing the right way in terms of X, but the Y the gun's always at an inverted angle. Do any of you know what the problem is? It's just using the simple "point at position in space" command, so that the gun points at the object that's at the right mouse position.

Pineapple juice, the best drink ever made.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 14th Jun 2006 22:04
Maybe the gun object's front is the back of the gun?
Use:



just after you load the gun model.

If that doesn't work, you need to post your code, or at least part of it. I doubt anyone would use it without asking

There are three types of people, those that can count and those that can't.
BLink
22
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 15th Jun 2006 21:56
Yeah, my code's just a clutter(organization wise, things are all over the place), so it was easier for me to post like this. I'll try Yrotating it in general, and maybe as well setting the pivot after turning around backwards? It only has this error facing backwards...

Pineapple juice, the best drink ever made.
BLink
22
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 20th Jun 2006 22:47
Alright, I took the time to write everything in a medialess form, my game has you flying a spaceship and aiming it with the mouse as it goes down a track( much like a 2d scrolling shooter) and in this form, you click your left mouse button to make a u-turn, and go the opposite way, which multiplies flow# by negative 1, so the flow will always be either 1 or -1, and that's which way you're going.



I added in as many remarks as I could to help, and I've cut down the code to the bare basics so you can see what's going on.

Pineapple juice, the best drink ever made.
BLink
22
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 23rd Jun 2006 08:00
I actually really do need help on this one. I'm going to have time tomorrow that's usually spent on programing( without internet and with it being the only time I really use on Dark Basic anymore), so if you guys could look at the code and at the least, give me a suggestion, even if you only glance at the code, I'll take almost anything. I'm just really really stuck on this, as my programming isn't experienced enough to known more ways to go about the problem...hence being stuck on it. Help!

Pineapple juice, the best drink ever made.
BLink
22
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 29th Jun 2006 01:57
It's been two weeks since I posted this originally, a week since I posted the code. Still need help.

Pineapple juice, the best drink ever made.
SFSW
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 30th Jun 2006 00:04
Here's your updated code to do what I think it is you want:



You just needed to use the ZYX rotation system for object 2.

BLink
22
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 30th Jun 2006 07:51
Yes, yes, yes! That's precisely it. I never understood that command, what exactly does it do to the object? It looks like it just flips it on every axis so it's practically inverted.

Thank you so much though!

Pineapple juice, the best drink ever made.
SFSW
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 30th Jun 2006 08:24
Certainly welcome I'm glad that got the result you wanted.

As far as I know, 'Set Object Rotation ZYX' simply reverses the order in which an object is rotated (starting with Z first, then Y, finally X, instead of the default XYZ, which visually flips the X angle when your object is turned around on Y). ZYX provides the proper orientation for an object in any direction if you want to use the Point Object command since X is adjusted last.

BLink
22
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 30th Jun 2006 09:19
So it's possible to do yxz as well? That might prove useful for other elements...

Pineapple juice, the best drink ever made.
SFSW
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 30th Jun 2006 19:17
I don't think so, only XYZ and ZYX. But I haven't run into a situation where a YXZ would be needed.

Login to post a reply

Server time is: 2026-07-06 20:31:40
Your offset time is: 2026-07-06 20:31:40