This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I can dash to the four directions relative to the camera, but only horizontally and can't quite get the verticality right. I want to be able to dash upwards or downwards at an angle.

This is the code for the dash right now:

velocity = dash_direction * DASH_SPEED
dash_direction = dash_direction.normalized()
velocity = velocity.rotated(Vector3(0,1,0), rotation.y)
velocity = move_and_slide(velocity, Vector3.UP)
Godot version 3.2
in Engine by (47 points)

I think we will need more code. Can you post the whole script maybe? specifically we will need to see where dash_direction is defined.

dash_direction is not specified and rotated is adding rotation. Do you have a working code example?

If this is a platformer / side-view situation, the problem might be that gravity is messing up with your vertical speed so the dashes don't feel right. Try disabling / counteracting the effect of gravity while you are dashing.

It's a 3D FPS game. This is how the dash function gets it's direction

    DASH:
        dash_direction = direction
        if direction == Vector3.ZERO:
            dash_direction -= head_basis.z

This is what defines direction

direction = Vector3()
head_basis = head.get_global_transform().basis
direction += (int(s) - int(w)) * head_basis.z
direction += (int(d) - int(a)) * head_basis.x

I'm having trouble on where to apply an angle and force to said angle.

Copy pasting here from another comment
It's a 3D FPS game. This is how the dash function gets it's direction

    DASH:
        dash_direction = direction
        if direction == Vector3.ZERO:
            dash_direction -= head_basis.z

This is what defines direction

direction = Vector3()
head_basis = head.get_global_transform().basis
direction += (int(s) - int(w)) * head_basis.z
direction += (int(d) - int(a)) * head_basis.x

I'm having trouble on where to apply an angle and force to said angle.

It's better to add code to the question to get the whole picture. And maybe empty one of your comments ;-) And I miss the mouse code too.

Ah, sorry, here it is.

func _input(event):
if event is InputEventMouseMotion:
    head.rotate_y(deg2rad(-event.relative.x * MOUSE_SENS))
    var x_delta = event.relative.y * MOUSE_SENS
    if camera_rotation + x_delta > -90 and camera_rotation + x_delta < 90:
        camera.rotate_x(deg2rad(-x_delta))
        camera_rotation += x_delta

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.