### RigidShape - Walk in the direction the camera is looking

Scripting questions, discussions, etc

#### RigidShape - Walk in the direction the camera is looking

noemen
Posts: 100
Joined: Tue May 29, 2018 3:46 pm

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).
Last edited by noemen on Wed Apr 01, 2020 4:16 am, edited 2 times in total.

#### Re: RigidShape - Walk in the direction the camera is looking

Duion
Posts: 1603
Joined: Sun Feb 08, 2015 1:51 am

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.

#### Re: RigidShape - Walk in the direction the camera is looking

noemen
Posts: 100
Joined: Tue May 29, 2018 3:46 pm

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.

#### Re: RigidShape - Walk in the direction the camera is looking

Duion
Posts: 1603
Joined: Sun Feb 08, 2015 1:51 am

Why not make a vehicle consisting of only one wheel?

#### Re: RigidShape - Walk in the direction the camera is looking

noemen
Posts: 100
Joined: Tue May 29, 2018 3:46 pm

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.

#### Re: RigidShape - Walk in the direction the camera is looking

fLUnKnhaXYU
Posts: 158
Joined: Wed Nov 15, 2017 8:19 am
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"));

#### Who is online

Users browsing this forum: No registered users and 5 guests