miércoles, 5 de marzo de 2025

GDScript para girar particulas 3d con Godot 4.4; ahora todo lo are con Godot 4.4; Adios Godot 4.3;

 extends CPUParticles3D


var rotation_speed : float = 2.0 # Velocidad de rotación en radianes por segundo


func _ready() -> void:

pass


func _process(delta: float) -> void:

rotate_y(rotation_speed * delta)


------------------------------------------------------------------------

otro ejemplo ampliando en eje "x"

---------------------------------------------------------------------------

extends CPUParticles3D


var rotation_speed : float = 2.0 # Velocidad de rotación en radianes por segundo


func _ready() -> void:

pass


func _process(delta: float) -> void:

rotate_y(rotation_speed * delta)

rotate_x(rotation_speed * delta)


martes, 4 de marzo de 2025

GDScript de sumar puntos ; al conseguir 8 puntos cambia a otra escena; esta asu vez se borra y retorna a la primera pasados unos segundos;Godot 4.3;


 extends Area3D


var score = 1


func _ready():

pass


func _on_area_entered(area: Area3D) -> void:

$Label.text = str(score)

score += 1


if score > 8:

get_tree().change_scene_to_file("res://TIAS EN PELOTAS/Hip Hop Dancing AMARILLA.tscn")



func _on_timer_timeout() -> void:

pass # Replace with function body.

--------------------------------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------- Estas 2 capturas de pantalla y GDScripts se complementan en un juego------------------------------------

---------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------





GDScript que reproduce una animacion 3d de un nodo, durante 7 segundos; luego cambia a la escena principal;Godot 4.3;


 extends Node3D


var timer = Timer.new()


func _ready() -> void:

$AnimationPlayer.play("mixamo_com")

add_child(timer)

timer.one_shot = true

timer.timeout.connect(_on_timer_timeout)

timer.start(7) # Inicia el temporizador de 3 segundos


func _on_timer_timeout():

get_tree().change_scene_to_file("res://MAPnode_3d.tscn") # Cambia a la escena "MAPnode_3d.tscn"


func _process(delta: float) -> void:

pass

domingo, 2 de marzo de 2025

Enemigo persigue a player en godot 4.3; GDScript del enemigo y del player; y lo nodos y graficos correspondientes;


 extends CharacterBody3D


const SPEED = 5.0

const ACCELERATION = 1.0 # Ajusta este valor para la velocidad de respuesta deseada

@onready var navAgent = $NavigationAgent3D

@onready var target = $"../Player"


func _physics_process(delta: float) -> void:

# Añadir gravedad.

if not is_on_floor():

velocity += get_gravity() * delta


if target: # Verifica si el objetivo existe

_update_target_position() # Actualiza la posición del objetivo primero


var currentLocation = global_transform.origin

var nextLocation = navAgent.get_next_path_position()

var nextVelocity = (nextLocation - currentLocation).normalized() * SPEED


velocity = velocity.move_toward(nextVelocity, ACCELERATION * delta) # Usa delta para suavizar la aceleración

move_and_slide()

else:

print("El objetivo (jugador) no existe.")


func _update_target_position():

if target:

navAgent.target_position = target.global_transform.origin

else:

print("El objetivo (jugador) no existe. No se puede actualizar la posición del NavigationAgent.")

----------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
Explicacion: el GDScript de encima es para poner al enemigo, es para Godot 4.3 en juego 3d, fijarse en la ilustracion en los nombres de los nodos y los graficos elementos del juego...... el GDScript  inferior es para mover al player.
--------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------
extends CharacterBody3D


const SPEED = 5.0
const JUMP_VELOCITY = 4.5


func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta

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

# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)

move_and_slide()