|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Pair of legs |
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.
|
|
|
|
Reply From: |
NerdKnight |
y_velo is not defined or used
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?
Pair of legs | 2021-06-04 17:41
I don’t see where you defined y_velo.
wyattb | 2021-06-04 23:21