miércoles, 27 de marzo de 2024

SCRIPT PARA GODOT 4.2 CUANDO TOCA UN AREA3D EL PLAYER CAMBIA SU ANIMACION Y PRODUCE UN SONIDO;

 extends Area3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass



func _on_area_entered(area):

$"../AnimationPlayer".play("EXPLOTA")

$"../AnimationPlayer/AudioStreamPlayer3D".play()

pass # Replace with function body.


martes, 26 de marzo de 2024

Una forma de audio para godot 4.2; Script gdscript; pulsando boton del mouse y soltando;

 extends AnimationPlayer


var audio_stream: AudioStream


func _ready():

audio_stream = load("res://EL SONIDO/RUJEScorto.ogg")

var audio_player = AudioStreamPlayer.new()

audio_player.stream = audio_stream

add_child(audio_player)


#func _on_AnimationPlayer_input_event(event):

func _input(event):




if event is InputEventMouseButton:




if event.button_index == 1:

$AudioStreamPlayer3D.play()



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

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

En el script de devajo al soltar la pulsacion se detiene el sonido , el script inferior es correcto....

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

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

extends AnimationPlayer


var audio_stream: AudioStream


func _ready():

audio_stream = load("res://EL SONIDO/RUJEScorto.ogg")

var audio_player = AudioStreamPlayer.new()

audio_player.stream = audio_stream

add_child(audio_player)


func _input(event):

if event is InputEventMouseButton:

if event.button_index == 1:  # Botón izquierdo del mouse

if event.pressed:

$AudioStreamPlayer3D.play()  # Reproduce el sonido al presionar

else:

$AudioStreamPlayer3D.stop()  # Detiene el sonido al soltar



lunes, 25 de marzo de 2024

Script para godot 4.2 para que cuando algo toque una rueda esta gire;

 extends MeshInstance3D



# Called when the node enters the scene tree for the first time.

func _ready():

pass # Replace with function body.



# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta):

pass


func _on_area_3d_area_entered(area):

rotate_y(2.5)

pass # Replace with function body.

-------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
Explicacion:
 partiendo de un nodo MeshInstance3D con hijo un Area3d y un nieto CollisionShape3D cuando algo toca el CollisionShape3D  el MeshInstance3D  gira, el script lo tiene el MeshInstance3D y la señal el Area3d......

martes, 19 de marzo de 2024

Scripts para Godot 4.2 que instancia una sola vez; por mouse y por temporizador ; y repetitivamente;

 extends Area3D


var Bullet = preload("res://ESCENAS/player.tscn")

var has_fired = false


func _ready():

pass


func _input(event):

if event is InputEventMouseButton && !has_fired:

if event.button_index == 1:

var bullet = Bullet.instantiate()

add_child(bullet)

has_fired = true


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

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

El de abajo instancia cada vez que se presiona boton del mouse

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

extends Area3D


var Bullet = preload("res://ESCENAS/player.tscn")


func _ready():


pass # Replace with function body.



func _input(event):


if event is InputEventMouseButton:


if event.button_index == 1:


var bullet = Bullet.instantiate()



add_child(bullet)

--------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
instancia ahora por tiempo a los 2 segundos transcurridos  constantemente
-------------------------------------------------------------------------------------------------------

extends Area3D

var Bullet = preload("res://ESCENAS/player.tscn")

func _ready():
# Iniciar un temporizador
$Timer.start(2.0)

#func _on_Timer_timeout():
# Instanciar la bala después de 2 segundos
#var bullet = Bullet.instantiate()
#add_child(bullet)


func _on_timer_timeout():
var bullet = Bullet.instantiate()
add_child(bullet)
------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Instancia una sola vez por tiempo al pasar 2 segundos
-------------------------------------------------------------------------------------------------------------------

extends Area3D

var Bullet = preload("res://ESCENAS/player.tscn")

var has_fired = false

func _ready():
# Iniciar un temporizador
$Timer.start(2.0)

#func _on_Timer_timeout():
# Instanciar la bala después de 2 segundos
#var bullet = Bullet.instantiate()
#add_child(bullet)


func _on_timer_timeout():
if not has_fired:
var bullet = Bullet.instantiate()
add_child(bullet)
has_fired = true


jueves, 14 de marzo de 2024

Brothel for retired women, juego echo con Godot 4.2 en 3dimensiones;

 

CSGCylinder3D APARECE DESAPARECE CADA 0.25 SEGUNDOS;

 extends CSGCylinder3D


var tiempo_transcurrido: float = 0.0 # Tiempo transcurrido desde el último cambio de estado


func _physics_process(delta):

# Acumular el tiempo transcurrido

tiempo_transcurrido += delta


# Cambiar la visibilidad del CSGCylinder3D cada 0.25 segundos

if tiempo_transcurrido >= 0.25:

visible = !visible # Invertir el estado actual de la visibilidad

tiempo_transcurrido = 0.0


Script GDScript completo en español para encender y apagar una luz cada 0.25 segundos;

 extends OmniLight3D


var tiempo_transcurrido: float = 0.0 # Tiempo transcurrido desde el último cambio de estado


func _physics_process(delta):

# Acumular el tiempo transcurrido

tiempo_transcurrido += delta


# Cambiar el estado de la luz cada 0.25 segundos

if tiempo_transcurrido >= 0.25:

visible = !visible # Invertir el estado actual de la luz

tiempo_transcurrido = 0.0