Jump to content

Movement of Objects


Foolish
 Share

Recommended Posts

I have been mining the forums for information on how to move objects in 3D space. I thought it was a significant enough topic to merit its own space.

 

For example, if I have two objects and I want to move object A to Object B's location. Is there an easy way to determine the vector I would need to set for SetBodyVelocity or even MoveEntity if I wasn't using Physics?

Windows XP

Dual Core 2.66

Dual GeForce 7900 GTS in SLI (Yes, I know they are old.)

Blitzmax with BlIDE

Link to comment
Share on other sites

Thanks Rick. I think I saw you had a post on this somewhere. I'll see if I can find it again. Also, I was checking out your latest Thingoid video. Good stuff I am looking forward to checking out further.

 

 

For non physics you can interpolate a number of steps between A & B and then each frame call SetPosition() along those steps. If the steps are small enough it will produce the same as MoveEntity and seem smooth.

Windows XP

Dual Core 2.66

Dual GeForce 7900 GTS in SLI (Yes, I know they are old.)

Blitzmax with BlIDE

Link to comment
Share on other sites

One of the problems getting out the starting gate for me has been these simple navigation issues. There aren't really to many examples to learn from.

 

Right now, I am trying to move a spaceship in 3D space. I can certainly move it using things like setvelocity, but its been difficult to figure out how to navigate to a specific point. With all of the complex problems people discuss on the forums, maybe this is too simple?

 

In two dimensions, I suppose I can figure out the angle using the arctangent. In 3 dimensions, I guess this would be something similiar. Then I guess I can use set velocity.

 

These things will get me from point a to point b, but then I need to apply a torque to get the ship to rotate and face the direction of movement. I was thinking that to keep the ship facing the right direction I would be continuously checking the angle and adding torque to keep pitch and roll where they need to be.

 

Anyway, if anybody has done this before and can validate this approach, let me know. Better yet, if you have an example, I wouldn't mind seeing that either.

Windows XP

Dual Core 2.66

Dual GeForce 7900 GTS in SLI (Yes, I know they are old.)

Blitzmax with BlIDE

Link to comment
Share on other sites

Okay, I'm onto something now. CalcBodyVelocity lets me get a vector for the velocity to a position I give it. Progress.

 

 

 

One of the problems getting out the starting gate for me has been these simple navigation issues. There aren't really to many examples to learn from.

 

Right now, I am trying to move a spaceship in 3D space. I can certainly move it using things like setvelocity, but its been difficult to figure out how to navigate to a specific point. With all of the complex problems people discuss on the forums, maybe this is too simple?

 

In two dimensions, I suppose I can figure out the angle using the arctangent. In 3 dimensions, I guess this would be something similiar. Then I guess I can use set velocity.

 

These things will get me from point a to point b, but then I need to apply a torque to get the ship to rotate and face the direction of movement. I was thinking that to keep the ship facing the right direction I would be continuously checking the angle and adding torque to keep pitch and roll where they need to be.

 

Anyway, if anybody has done this before and can validate this approach, let me know. Better yet, if you have an example, I wouldn't mind seeing that either.

Windows XP

Dual Core 2.66

Dual GeForce 7900 GTS in SLI (Yes, I know they are old.)

Blitzmax with BlIDE

Link to comment
Share on other sites

I bet it will be familiar. ;) I am using a TIE Fighter from the classic Star Wars trilogy.

 

I will get that image in here ASAP.

 

In the meantime, I have playing around with the CalcBodyVelocity and SetBodyVelocity. I added a list of waypoints for the TIE Figher to follow. Unforunately, I can't figure out how to set a "constant velocity". My ship is decelerating as it gets close to the waypoint. My logic is as follows.

 

1. Identify the next way point.

2. Calculate the velocity. Set the velocity. Note that I calc and set the velocity once for each waypoint.

3. Each update cycle, check to see if my distance from the pivot is <=1. If so, go back to step 1.

 

Overall, this is probably not the way to do it, but I am still playing.

Windows XP

Dual Core 2.66

Dual GeForce 7900 GTS in SLI (Yes, I know they are old.)

Blitzmax with BlIDE

Link to comment
Share on other sites

  • 2 weeks later...

I changed directions a little bit and started focusing on piloting the ship manually as opposed to workign on AI controlled ships first.

 

So getting some basics down were pretty easy. The third person cam was just:

 

'Position Camera

PositionEntity(cam, EntityPosition(thismodel.model))

RotateEntity(cam, EntityRotation(thismodel.model))

MoveEntity(cam, Vec3(0, 1, - 2.5))

 

I have a Type for my TIE Fighter. The model needed the following characteristics:

EntityType model, 1

SetBodyMass model, 10

SetBodyDamping(model, 1, 2) The first param is linear damping and the second is angular.

SetBodyGravityMode model, False 'no falling in space.

SetBodyFriction (model, 0, 0)

 

In the update method, I just use the following to steer:

 

pitch = (KeyDown(KEY_UP) - KeyDown(KEY_DOWN)) * 200

 

yaw = (KeyDown(KEY_RIGHT) - KeyDown(KEY_LEFT)) * 200

 

roll = (KeyDown(KEY_Z) - KeyDown(KEY_X)) * 250

 

AddBodyForce(model, Vec3(0, 0, 700), 0)

 

AddBodyTorque model, Vec3(pitch, yaw, roll), 0

 

The AddBodyForce is thrust and the torque obviously impacts the orientation. Using physics forces on Star Wars ships makes for an interesting flight experience that I think will make the dog fighting interesting.

 

 

The attached screenshot shows my place holder graphics of a TIE fighter flying over the Death Star surface.

 

 

 

 

 

 

I bet it will be familiar. :) I am using a TIE Fighter from the classic Star Wars trilogy.

 

I will get that image in here ASAP.

 

In the meantime, I have playing around with the CalcBodyVelocity and SetBodyVelocity. I added a list of waypoints for the TIE Figher to follow. Unforunately, I can't figure out how to set a "constant velocity". My ship is decelerating as it gets close to the waypoint. My logic is as follows.

 

1. Identify the next way point.

2. Calculate the velocity. Set the velocity. Note that I calc and set the velocity once for each waypoint.

3. Each update cycle, check to see if my distance from the pivot is <=1. If so, go back to step 1.

 

Overall, this is probably not the way to do it, but I am still playing.

post-250-12697842007343_thumb.jpg

Windows XP

Dual Core 2.66

Dual GeForce 7900 GTS in SLI (Yes, I know they are old.)

Blitzmax with BlIDE

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...