0 votes

Here's my code

extends KinematicBody
var direction = Vector3.FORWARD
var MOVE_SPEED = 16
const JUMP_FORCE = 20
const GRAVITY = 0.98
var MAX_FALL_SPEED = 0.40
const MAX_WALL_SLIDE_SPEED = 120
const WALL_SLIDE_ACCELERATION = 10
const Drill_speed = -40.9
const H_LOOK_SENS = 1.0
const V_LOOK_SENS = 1.0
var jump_change = false
var grounded = true
if is_on_floor():
        grounded = true
    else:
        grounded = false
    y_velo -= GRAVITY
    var just_jumped = false
    if Input.is_action_just_pressed("jump"):
        if grounded == true:
            just_jumped = true
            y_velo = JUMP_FORCE
        if grounded == false and jump_change == false and is_on_wall() == false:
            jump_change = true
            y_velo = Drill_speed
        if grounded == false:
            jump_change = false


    if grounded and y_velo <= 0:
        y_velo = -0.1
    if y_velo < -MAX_FALL_SPEED:
        y_velo = -MAX_FALL_SPEED

I'm trying to make a ground pound with no lag but for some reason every time I increase Drill_speed it does nothing. Sorry if this is formatted wrong. I'm new here.

Godot version V3.3
in Engine by (12 points)

2 Answers

+2 votes

y_velo is not defined or used

by (32 points)

Oof. I forgot to add y_velo in shown code.
Updated code

extends KinematicBody
var direction = Vector3.FORWARD
var MOVE_SPEED = 16
const JUMP_FORCE = 20
const GRAVITY = 0.98
var MAX_FALL_SPEED = 0.40
const MAX_WALL_SLIDE_SPEED = 120
const WALL_SLIDE_ACCELERATION = 10
const Drill_speed = -40.9
const H_LOOK_SENS = 1.0
const V_LOOK_SENS = 1.0
var jump_change = false
var grounded = true

func _physics_process(_delta):
    var move_vec = Vector3()

move_vec = move_vec.normalized()
    move_vec = move_vec.rotated(Vector3(0, 1, 0), rotation.y)
    move_vec.y = y_velo

if is_on_floor():
        grounded = true
    else:
        grounded = false
    y_velo -= GRAVITY
    var just_jumped = false
    if Input.is_action_just_pressed("jump"):
        if grounded == true:
            just_jumped = true
            y_velo = JUMP_FORCE
        if grounded == false and jump_change == false and is_on_wall() == false:
            jump_change = true
            y_velo = Drill_speed
        if grounded == false:
            jump_change = false


    if grounded and y_velo <= 0:
        y_velo = -0.1
    if y_velo < -MAX_FALL_SPEED:
        y_velo = -MAX_FALL_SPEED

Can you fix the ground pound with this new code please?

I don't see where you defined y_velo.

0 votes

where is the error?

by (213 points)
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 webmaster@godotengine.org with your username.