domingo, 21 de abril de 2024

Desde un Area3d Rota label3d constantemente y lo escala a mayor , borra SoftBody3, borra CollisionShape3D; GDScript Godot 4.2;

 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):

$Label3DDICEIMBECIL.rotate_y(delta * 1.9)

pass



func _on_area_entered(area):

var escala_actual = $Label3DDICEIMBECIL.scale

$Label3DDICEIMBECIL.scale = escala_actual * 18.0

var parent = get_parent()

var Turbo = parent.get_node("$SoftBody3Dvestido")

$SoftBody3Dvestido.queue_free()

$CollisionShape3Dquieroborrartambien.queue_free()

pass # Replace with function body.

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

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

Exlicacion: desde enlace muy buenos estos scripts...https://videojuegosenlineaasaco4.blogspot.com/2024/04/borrar-elementos-concretos-de-un-area3d_21.html

Borrar elementos concretos de un Area3D mediante scriptGDScript Godot 4.2; + poner un Label3d de texto que se amplia en esa colision;

 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):

var escala_actual = $Label3DDICEIMBECIL.scale

$Label3DDICEIMBECIL.scale = escala_actual * 2.0

var parent = get_parent()

var Turbo = parent.get_node("$SoftBody3Dvestido")

$SoftBody3Dvestido.queue_free()

$CollisionShape3Dquieroborrartambien.queue_free()

pass # Replace with function body.


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

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

EXPLICACION Y CAPTURA DE PANTALLA:

Tengo un personaje en Godot3d 4.2 al que por colision quiero borrarle el vestido, en el script me encontre con fallos que provocaban que el juego se bloquease, cuando el player tocaba  al personaje le borraba el vestido y funcionaba bien, pero cuando lo volvia a tocar se bloqueaba el juego porque ....no borraba tambien el CollisionShape3Dquieroborrartambien que producia la orden de borrar el vestido, entonces entendi que al volver a tocar ese CollisionShape3Dquieroborrartambien que en el script mandaba borrar el SoftBody3Dvestido y el programa al correr veia que no existia ese elemento a borrar porque ya se hizo anteriormente, se contradecia y se paraba ,bloqueaba el juego, SOLUCION.......borrar tambien al colisionar, tocar,  ese CollisionShape3Dquieroborrartambien y asi e conseguido solucionar ese bloqueo del juego, e tenido que pensar y razonar y me cuesta mucho la verdad, se me da muy mal programar, pero no me queda otra, si no imposible desarrollar con Godot 4.2

Hemos ampliado el script con nuebo elemento un label3d que pone un texto en 3d, lo escala en esa colision y en el script e señalado las dos lineas nuevas de verde todo funciona perfectamente...







Borrar elementos concretos de un Area3D mediante scriptGDScript Godot 4.2;

 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):

var parent = get_parent()

var Turbo = parent.get_node("$SoftBody3Dvestido")

$SoftBody3Dvestido.queue_free()

$CollisionShape3Dquieroborrartambien.queue_free()

pass # Replace with function body.

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

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

EXPLICACION Y CAPTURA DE PANTALLA:

Tengo un personaje en Godot3d 4.2 al que por colision quiero borrarle el vestido, en el script me encontre con fallos que provocaban que el juego se bloquease, cuando el player tocaba  al personaje le borraba el vestido y funcionaba bien, pero cuando lo volvia a tocar se bloqueaba el juego porque ....no borraba tambien el CollisionShape3Dquieroborrartambien que producia la orden de borrar el vestido, entonces entendi que al volver a tocar ese CollisionShape3Dquieroborrartambien que en el script mandaba borrar el SoftBody3Dvestido y el programa al correr veia que no existia ese elemento a borrar porque ya se hizo anteriormente, se contradecia y se paraba ,bloqueaba el juego, SOLUCION.......borrar tambien al colisionar, tocar,  ese CollisionShape3Dquieroborrartambien y asi e conseguido solucionar ese bloqueo del juego, e tenido que pensar y razonar y me cuesta mucho la verdad, se me da muy mal programar, pero no me queda otra, si no imposible desarrollar con Godot 4.2



miércoles, 17 de abril de 2024

Script para animar humanoide y rotarlo a si mismo desde un nodo3d para godot 4.2;

 extends Node3D



# 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):

rotate_y(0.1)

$AnimationPlayer.play("LAENFADA")

pass


martes, 16 de abril de 2024

Script borra softbody3d de un personaje el vestido; godot 4.2; Script PARA RigidBody3D Y ALOS 3 SEGUNDOS LO BORRA ;

 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):

$"LA VIEJA/SoftBody3D".queue_free()

$"LA VIEJA/SoftBody3D3".queue_free()

$"LA VIEJA/SoftBody3D4".queue_free()

$"LA VIEJA/SoftBody3D2".queue_free()

pass # Replace with function body.

------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
EXPLICACION:  De un Area3d (donde e puesto el script) parten 2 hijos "la vieja" (un node3D) y el otro un CollisionShape3D....los SoftBody3D los cuatro diferentes del script son hijos del "la vieja" (un node3D) y nietos del area3d principal . funciona a la perfeccion cuando el player choca con  CollisionShape3D  se borra el vestido ,este ejemplo es de arriba, abajo otra variante que funciona en el cubo en la ropa no funciona............¡¡atencion estos scripts cuando repite  colisionar el juego se bloquea!! aun tiene fallos.........
--------------------------------------------------------------------------------------------------------------------------
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):
#$"LA VIEJA/SoftBody3D3".queue_free()
#$"LA VIEJA/SoftBody3D4".queue_free()
#$"LA VIEJA/SoftBody3D2".queue_free()
#$"LA VIEJA/CSGBox3Dgira".rotate_x(1)
$"LA VIEJA/CSGBox3Dgira".scale /= 2.5
$"LA VIEJA/SoftBody3D".scale /= 0.005
$"LA VIEJA/SoftBody3D2".scale /= 0.005
$"LA VIEJA/SoftBody3D3".scale /= 0.005
$"LA VIEJA/SoftBody3D4".scale /= 0.005
pass # Replace with function body.



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

ESTE DE DEBAJO SI FUNCIONA SIN PROBLEMAS , SE PONE A UN  RigidBody3D Y ALOS 3 SEGUNDOS LO BORRA NO NECESITA SEÑAL TAMPOCO.
-------------------------------------------------------------------------------------------------------------
extends RigidBody3D

var timer = 0.0

func _physics_process(delta):
# Incrementar el temporizador
timer += delta

# Eliminar el RigidBody3D después de 3 segundos
if timer >= 3.0:
queue_free()


lunes, 15 de abril de 2024

GDScript proboca explosion y borra barco y sale barco roto, instancia explosion bolas instancia barco roto y borra barco sin destruir;

 extends Area3D


var esfera_prefab = preload("res://BARCO Y ELEMENTOS DEL BARCO/BOTE/BOTECAIDO.tscn")  # Precarga el prefab del barco (bote caído)

var explosion_prefab = preload("res://ESCENAS/EXPLOSION BAJO BOTE.tscn")  # Precarga el prefab de la explosión (invento genial)


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

func _ready():

pass  # No hay necesidad de código inicial en este ejemplo


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

func _process(delta):

pass  # No hay necesidad de código por frame en este ejemplo


# Detecta cuando otro nodo entra en el área

func _on_area_entered(area):

# Verifica si el objeto que entró tiene un nodo CollisionShape3D

if area.has_node("CollisionShape3D"):


var barco_instancia = esfera_prefab.instantiate()


# Crea una instancia del prefab de la explosión (invento genial)

var explosion_instancia = explosion_prefab.instantiate()


# Agrega las instancias como hijos de este nodo

add_child(barco_instancia)

add_child(explosion_instancia)


# Detecta cuando otro nodo sale del área (opcional)

func _on_area_exited(area):

var parent = get_parent()


var CollisionShape3Dcubo = parent.get_node("CollisionShape3D")


get_node("CollisionShape3D").queue_free()  # Intento de eliminar CollisionShape3D propio (comentado)

---------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------
EXPLICACION:::::::
estructura padres e hijos .. padre principal de todo  WorldEnvironment hijo donde esta el script un Area3d esta tiene de nieto un CollisionShape3D de este sale dos vicnietos un MeshInstance3D y otro MeshInstance3D con nombre "bote2


Instancia bolas cuando entra en un Area3d el player y cuando presiona boton del mouse, para godot 4,2 3D; GDScript;

 extends Area3D


var Bullet = preload("res://ESCENAS/EXPLOSION BAJO BOTE.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)



func _on_area_entered(area):

var bullet = Bullet.instantiate()



add_child(bullet)

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

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

En el script de debajo funciona solo cuando pasa por su Area3d, pusimos signo"#" a lo que no queremos que ejecute

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

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

extends Area3D var Bullet = preload("res://ESCENAS/EXPLOSION BAJO BOTE.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) func _on_area_entered(area): var bullet = Bullet.instantiate() add_child(bullet)