#Character won't move

30 messages · Page 1 of 1 (latest)

willow jetty
#

func _physics_process(delta):
  # Add the gravity.
  if not is_on_floor():
    velocity.y -= gravity * delta

# Handle jump.
  if Input.is_action_just_pressed("jump") and is_on_floor():
    velocity.y = JUMP_VELOCITY

# Handle Sprint.
  if Input.is_action_pressed("sprint"):
    speed = SPRINT_SPEED
  else:
    speed = WALK_SPEED

# Get the input direction and handle the movement/deceleration.
  var input_dir = Input.get_vector("left", "right", "up", "down")
  var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

# Move the character.
  move_and_slide(velocity, Vector3.ZERO, 0.0)

# Update the velocity.
  if is_on_floor():
    if direction:
      velocity.x = direction.x * speed
      velocity.z = direction.z * speed
    else:
      velocity.x = lerp(velocity.x, direction.x * speed, delta * 7.0)
      velocity.z = lerp(velocity.z, direction.z * speed, delta * 7.0)
  else:
    velocity.x = lerp(velocity.x, direction.x * speed, delta * 3.0)
    velocity.z = lerp(velocity.z, direction.z * speed, delta * 3.0)

tender bluff
#

did you call move_and_slide()?

#

can you send the full code formatted with three `?

#
like this
#

reading, 1 sec

#

I don't see move_and_slide() being called here, can you show the code that includes that? or if it isn't there, then include it at the end of all the velocity modifications for the velocity to take effect

#

oh ok

#

not quite sure the issue here to be honest

#

I chose a wrong time to help you as I have to leave now, i'm sorry

#

if the issue isnt fixed i can come back in a few hours to help

#

is this 3D or 2D?

#

I have an idea that may or may not work

#

but first, when did this error start

#

I have to leave in a few minutes, so im trying to help all I can before then

tender bluff
#

this is probably stupid but try

 # Add the gravity.
    if not is_on_floor():
        velocity.y -= gravity * delta
    else:
        velocity.y = -0.02
#

oof hmm

#

do any warnings/errors show

#

maybe or maybe not

#

did everything work before

#

did you test everything while going through the tutorial, or did you do everything at once and test after

#

sometimes it doesnt between versions, even if its just 4.1 to 4.2

#

really hoped I couldve helped you

#

im very sorry

#

i gotta go now

#

i wish you best of luck

#

maybe redo the tutorial and test through it to catch the error before it sneaks past

deep heron
#

Likely a stupid question but it has to be asked : Have you set the input bindings properly, in the Project Settings?

#

The input names are case-sensitive also, just fyi

#

you should set "left", "right", "up", "down", "jump" and "sprint" with your prefered keybinds