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.

DLL Talk / EZRotate Orbit Rotations

Author
Message
z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 6th May 2007 14:44 Edited at: 6th May 2007 14:50
Hi!

I just purchased EZRotate and it seems very powerful. I modified the code for the orbit rotation example so that the door could be placed anywhere and the rotation would still work. I changed the "Orbiting Door from Left Side" portion to this:



The door acts strangely and not how I expected. Could anyone explain why this happens?

I am doing something simmilar to this in my own game, to rotate a laser beam in the direction the gun is facing.

EDIT: Here is the code for the laser in my own game. I get a simmilar problem:



Thanks in advance!

~ z_man ~
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 7th May 2007 19:53
z_man,

To perform an "orbit", EZrotate must alter the rotation and position of your object. In your code, you are using current position as part of the orbit axis. So, as the object moves and rotates, you are alos moving the orbit axis that you are setting up EZroate with!

z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 8th May 2007 09:40
Thanks! Now I get why this is happening, could you maybe explain how I could make it rotate relative to it's position?

Thanks in advance!

~ z_man ~
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 8th May 2007 13:06
Well, it needs to be anchored to something.

I think I understand what you are trying to do. You are just approaching it from the wrong perspective. The orbit command is going to mosify your object's position. I assume that your object is also movable, so it's position can be moved by other things too.
What you need to do is store a theoretical position for your object.

So, as you move your object around, you should modify some variable like this:


Now, as you press the arrow keys, variables that would store the object's theoretical poition would be modified.

Now, you would set up EZrotate like this, using the theoretical position as the orbiting axis.



It should work something like that. I haven't tested it (and my brain doesn't seem to be working correctly today) so I don't know for sure. Try something like this and let me know how you make out. If it doesn't work, I'll try to write a real example for you!

-Ron

z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 9th May 2007 11:30
Hi!

I did as you said but there still seems to be a problem - here is the example modified to what you said:



Is there something I'm doing wrong?

Thankyou!

~ z_man ~
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 9th May 2007 15:29
I told you my brain wasn't working correctly!

Here, try this:



Now, this is only really in effect while you are in Mode 1. Anyway, to help visualize the problem, I have added 3 spheres. Sphere 100 (colored red) is being positioned at the door's origin. The two other spheres are used to describe the rotation axis. As you press the arrow keys, the entire arrangement will now move around.
I hope this helps!

-Ron

z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 10th May 2007 15:04 Edited at: 10th May 2007 15:11
Thanks so much! It is a great example. I am now adding the idea into my own game, but I have run into another problem. Here is the portion of my code which does all the laser creating:



It does a simmilar thing to what happened in the code in my last post. Can you find any errors in the way my code is working with EZRotate above, because I don't seem to be doing something right, I can't seem to work it out...

I'm really sorry for the big jumble of code, and I've tried to make things clear by commenting each part.

These variables are to do with the character:

charX# is the character's X position
charY# is the character's Y position
charZ# is the character's Z position

charATTACK# is whether the character is attacking or not

charKPshoot# is whether the key to shoot is being pressed

The enemy array is assigned to a type and I will try to clear things up by explaining the variables/types.

.x is the x position of the laser
.y is the y position of the laser
.z is the z position of the laser

.xFrom is the x position from where the laser starts
.yFrom is the y position from where the laser starts
.zFrom is the z position from where the laser starts

.xTo is the x position from where the laser starts
.yTo is the y position from where the laser starts
.zTo is the z position from where the laser starts

Sorry about this big problem, but I have been trying to fix it for quite a few days now, without success, and I am quite new to DBPro.

Thanks very much for your support!

z_man

~ z_man ~
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 10th May 2007 16:37
z_man,
It is difficult for me to tell exactly what is going on. How much code is ther in your project? Could you e-mail me a copy of your project? It might be easier for me to tell what is going on if I can compile and test things. Better yet, if you could put together a snippet that can be compiled that shows your problem, it would be MUCH easier for me to help you

-Ron

z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 11th May 2007 09:28
Hi!

I have construced an example for you. When the character moves, while holding the laser button (shift) the laser seems to go offset and strange.

Here is the code (no extra media required):



Thanks!

z_man

~ z_man ~
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 11th May 2007 22:59
z_man,

The problem is that you are not changing your laser's position whenever your object moves. Try changing your movement code to this:



z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 12th May 2007 05:35 Edited at: 12th May 2007 05:37
Thankyou! It works great with that! I have one more question - how can I set the angle to Laser(i).Angle, instead of adding 1 each time. I don't want to add 1 to it all the time, I just want to make it face the direction the character is facing.

Thanks again,

z_man

~ z_man ~
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 13th May 2007 20:28
Sorry z_man, I have been busy all weekend. I'll try to look at this tonight or tomorrow!

Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 14th May 2007 06:41
OK.....
I finally got a few spare minutes.
Here is a new snippet that does what you are asking for.



z_man
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: Australia
Posted: 18th May 2007 09:25 Edited at: 18th May 2007 09:27
Thankyou so much, my problem is now solved and I understand how orbit works much better now! I have been away all week, so sorry for the late reply.

Thanks again,

z_man

~ z_man ~
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 18th May 2007 13:46
No problem! I'm glad that I was able to help

Login to post a reply

Server time is: 2024-05-20 16:36:48
Your offset time is: 2024-05-20 16:36:48