#Error Operator Script ... Nil, float ...

11 messages · Page 1 of 1 (latest)

deep inlet
#

I've had the problem for 2 weeks that I only get error messages that didn't exist before. Nil, float, Vector3, operator... I can't put gravity * delta in the script without error. Constantly red. That wasn't before. Constant error with various scripts from github ... thanks ...

vapid iris
#

You can't be this vague if you want help. You need to provide the exact error, show the code that causes it, etc

deep inlet
#

okay, I have error velocity = gravity * delta ... because of operator (Nil, float, Vector3) I'll put in a new script tomorrow, which has always worked. If the error comes again, I'll post it here ... sorry, I've been working 7 - 8 hours a day here for 8 months for my game and sometimes I don't have an overview ...

😀

deep inlet
deep inlet
# vapid iris You can't be this vague if you want help. You need to provide the exact error, s...

func _physics_process(delta: float) -> void:
var moveDirection : Vector3 = Vector3.ZERO

# calculate movement direction based on input and look direction
moveDirection.x = Input.get_axis("move_left", "move_right")
moveDirection.z = Input.get_axis("move_forward", "move_back")
moveDirection = moveDirection.rotated(Vector3.UP, cameraRig.rotation.y).normalized()

# apply movement to velcity
_velocity.x = moveDirection.x * speed
_velocity.z = moveDirection.z * speed

# apply gravity
_velocity.y -= gravity * delta
vapid iris
#

None of this code would make the player actually move. Do you have any code that would do that?

#

Like are you calling move_and_slide anywhere?

deep inlet
#

The script works with KinematicBody Capsule perfect. I have move_and_slide in it ... but my 3D Model not run ... 😀

#

var justLanded : bool = is_on_floor() && _snap_vector == Vector3.ZERO
var isJumping : bool = is_on_floor() && Input.is_action_just_pressed("jump")

# jump if we are allowed to
if isJumping:
    _velocity.y = jumpStrength
    _snap_vector = Vector3.ZERO
elif justLanded:
    _snap_vector = Vector3.DOWN

# finally apply movement
_velocity = move_and_slide_with_snap(_velocity, _snap_vector, Vector3.UP, true)
vapid iris
#

Is your 3d model a child of this node?

deep inlet
#

Capsule and Player are different, only same script for test ...