extends CharacterBody3D
var rotate_speed = 10.1 # Rotation speed
const SPEED = 0.2 # Movement speed
const JUMP_VELOCITY = 4.5 # Jump velocity
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _ready():
# Replace with function body
pass
func _physics_process(delta):
#translate(Vector3(0,0,-0.005))# PARA UNA CONSTANCIA DE MOVIMIENTO CONTINUO
translate(Vector3(0,0,-0.00))# PARA UNA CONSTANCIA DE MOVIMIENTO CONTINUO
if not is_on_floor():
velocity.y -= gravity * delta # Apply gravity
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY # Jump
#var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") # Get input direction
var input_dir = Input.get_vector("ui_left", "ui_right", "andaradelante", "detenerse") #ESTE FUNCIONABA ESTE FUNCIONABA
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED # Move in X direction
velocity.z = direction.z * SPEED # Move in Z direction
else:
velocity.x = move_toward(velocity.x, 0, SPEED) # Stop horizontal movement
velocity.z = move_toward(velocity.z, 0, SPEED) # Stop vertical movement
move_and_slide() # Apply movement and collisions
var movimiento_vector = Vector3.ZERO # Initialize movement vector
if Input.is_action_pressed("move_left"):
rotate_y(0.05) # Rotate on Z axis (positive for left)
if Input.is_action_pressed("move_right"):
rotate_y(-0.05) # Rotate on Z axis (negative for right)
#translate(Vector3(0.05,0,0))
if Input.is_action_pressed("detenerse"):
translate(Vector3(0.0,0.00,0.005))
rotate_y(-0.00)
if Input.is_action_pressed("andaradelante"):
translate(Vector3(0.0,0.00,-0.005))
rotate_y(-0.00)
move_and_slide()
# Movimiento basado en el botón izquierdo del ratón (acción "mouse_left")
if Input.is_action_pressed("mouse_left"):
# Mover hacia adelante
translate(Vector3(0.0, 0.00, -0.02))