#Error Operator Script ... Nil, float ...
11 messages · Page 1 of 1 (latest)
You can't be this vague if you want help. You need to provide the exact error, show the code that causes it, etc
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 ...
😀
I installed the old script, Player & Cam. At first it runs without errors. All variables/declarations are determined with export (float). My capsule is working fine. My player is rotating but not running???
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
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?
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)
Is your 3d model a child of this node?
Capsule and Player are different, only same script for test ...