Skip to content

Moving in a 3D space #13

Answered by mholtkamp
olivierpls asked this question in Q&A
Jul 27, 2024 · 3 comments · 6 replies
Discussion options

You must be logged in to vote

I'm glad you were able to solve your original problem!

I think you are having trouble moving at an angle because you are overwriting directionPoule. If Z is pressed, then you set directionPoule, but if Q is also pressed then you are resetting directionPoule before you ever set the new position.

Maybe something like this would work:

    local forward = self.poule:GetForwardVector()
    local right = self.poule:GetRightVector()

    directionPoule = Vec(0, 0, 0) 

    -- Avancer
    if (Input.IsKeyDown(Key.Z)) then
        directionPoule = directionPoule - forward
    end
    -- Reculer
    if (Input.IsKeyDown(Key.S)) then
        directionPoule = directionPoule + forward
    end
    -- All…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@mholtkamp
Comment options

Answer selected by olivierpls
@olivierpls
Comment options

@mholtkamp
Comment options

@olivierpls
Comment options

Comment options

You must be logged in to vote
1 reply
@mholtkamp
Comment options

Comment options

You must be logged in to vote
1 reply
@mholtkamp
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants