Jump to content

RigidShape - Walk in the direction the camera is looking


Recommended Posts

I'm doing some tests with RigidShape. I created a ball to be controlled instead of the Player. I managed to create a control, where the ball follows according to the keyboard (w, s, a and d) and placed an Orbit Camera on the object.


So far so good, but the problem is that the object does not move in the direction where the camera is looking. Example:


If the camera is looking at the X axis and pressing the W keyboard, I wanted the object (ball) to move to the X axis where the camera is looking. As well as if the object is stopped, the camera can rotate freely without moving the object (ball).

A great example is the game Marble Blast, I want the ball to have the same mechanics as Marble (in relation to the camera, because the movement is already ok).

Edited by noemen
Link to post
Share on other sites

Why don't you just replace the character with a ball and adjust the physics of the player data? Or use a vehicle, since I can imagine the physics of a vehicle can match those of a ball more.

 

@Duion Thank you very much. I will do some tests.

I was taking a look at the documentation and saw that it has getRotation (). I will see if I can capture the rotation of the camera and change the movement of the ball according to the camera.

Link to post
Share on other sites

I looked right here and decided to simplify everything ... Because the prototype was not pleasant. But I believe that the doubt of this topic can help other people. And whoever can answer, will be helping those who need help.


As I decided not to go deeper, but I believe that this can be solved as follows:


You would take the camera rotation with getRotation () and try to modify the control according to the camera.


@Duion Thank you very much for helping me, I ended up having other ideas.

Link to post
Share on other sites

with this little line you can hold freelook , move the camera , excute this line and it will apply impulse to the player in the direction of the camera view , I guess the program adds the player rotation to the camera .



 

%player.applyimpulse(%player.getposition(),vectorscale(%player.geteyevector(),"10000 10000 10000"));
Link to post
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.

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.

×
×
  • Create New...