Jump to content

moving objects in direction that its rotation is pointing


solartistic
 Share

Recommended Posts

Hello there, I am having a problem.

I am trying to create a function with (position, rotation and speed) in its artibutes, that will return a new position.

Like in the title i want the returned position to be the point that the rotation of the object its pointing in the distance of "speed"

if I am not clear, imagine a spaceship that travels in space in any direction it wants but always with its prow pointing forward;

I think free cameras moves in similar way;

I've made a demo with a function "fly" that is completly wrong

http://playground.babylonjs.com/#1RLOQY#1

Can you please try to help me? :)

Link to comment
Share on other sites

Hello there, I am having a problem.

 

I am trying to create a function with (position, rotation and speed) in its artibutes, that will return a new position.

Like in the title i want the returned position to be the point that the rotation of the object its pointing in the distance of "speed"

 

if I am not clear, imagine a spaceship that travels in space in any direction it wants but always with its prow pointing forward;

 

I think free cameras moves in similar way;

 

I've made a demo with a function "fly" that is completly wrong

http://babylonjs-playground.azurewebsites.net/#1RLOQY#1

 

Can you please try to help me? :)

I think what you want is to move the ship in local space right? Relative to the object?

 

Use: 

mesh.rotate(BABYLON.Axis.Z, 0.01, BABYLON.Space.LOCAL);mesh.translate(BABYLON.Axis.Y, 0.1, BABYLON.Space.LOCAL);

Example

Link to comment
Share on other sites

Hi Temechon,

Ive already knew that algoritm and it is for translating on planes only, it would work for me if the rotation.x and the rotation.z is 0, but the object im trying to move is flying.

 

TriBlade9:

By the time my post was displayed and it was responded, i've learned about "localyTranslate" function and I think the result is similar. Thank you for your solution too. :)

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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...