lunes, 29 de enero de 2024

Script para Godot version3.5 mover un objeto con teclas;

 extends RigidBody


var velocity = Vector3()


func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()


# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):

velocity.x -= 1

if Input.is_action_pressed("ui_right"):

velocity.x += 1

if Input.is_action_pressed("ui_up"):

velocity.y += 1

if Input.is_action_pressed("ui_down"):

velocity.y -= 1


# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)

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

otra forma

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

extends RigidBody


var velocity = Vector2()


func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()


# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):

velocity.x -= 10 * delta

if Input.is_action_pressed("ui_right"):

velocity.x += 10 * delta

if Input.is_action_pressed("ui_up"):

velocity.y += 10 * delta

if Input.is_action_pressed("ui_down"):

velocity.y -= 10 * delta


# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)

----------------------------------------------------------------------------------------------------------------------
otra combinacion

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

extends RigidBody




var velocity = Vector2()



func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()



# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):

velocity.x -= 10 * delta

if Input.is_action_pressed("ui_right"):

velocity.x += 10 * delta

if Input.is_action_pressed("ui_up"):

velocity.z -= 10 * delta

if Input.is_action_pressed("ui_down"):

velocity.z += 10 * delta



# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)




------------------------------------------------------------------------------------------------------------
otra version alante atras izquierda derecha suve y baja
------------------------------------------------------------------------------------------------------
extends RigidBody




var velocity = Vector2()



func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()



# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):

velocity.x -= 10 * delta

if Input.is_action_pressed("ui_right"):

velocity.x += 10 * delta

if Input.is_action_pressed("ui_up"):

velocity.z -= 10 * delta

if Input.is_action_pressed("ui_down"):

velocity.z += 10 * delta



if Input.is_action_pressed("ui_accept"):
velocity.y += 10 * delta
if Input.is_action_just_pressed("ui_end"):
velocity.y -= 20 * delta






# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)


-------------------------------------------------------------
otra girando sobre si mismo una parte
-------------------------------------------------------------------------------

extends RigidBody




var velocity = Vector2()



func _physics_process(delta):

# Obtener la velocidad actual del RigidBody

velocity = get_linear_velocity()



# Ajustar la velocidad según las teclas presionadas

if Input.is_action_pressed("ui_left"):
   rotate_y(-10 * delta)
#velocity.x -= 10 * delta

if Input.is_action_pressed("ui_right"):

velocity.x += 10 * delta

if Input.is_action_pressed("ui_up"):

velocity.z -= 10 * delta

if Input.is_action_pressed("ui_down"):

velocity.z += 10 * delta



if Input.is_action_pressed("ui_accept"):
velocity.y += 10 * delta
if Input.is_action_just_pressed("ui_end"):
velocity.y -= 20 * delta






# Aplicar la nueva velocidad al RigidBody

set_linear_velocity(velocity)







domingo, 28 de enero de 2024

Instanciar en Godot solo me funciona en la version 3 de godot no en la 4.2;

 extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



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

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





func _on_Timer_timeout():

spawn_ProjCopies()

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

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

EXPLICACION : SI QUIERES INSTANCIAR OBJETOS DENTRO DE UNA ESCENA USA LA VERSION 3 DE GODOT DONDE TIENE EL NODO SPATIAL LA VERSION 4.2 LLEVO SEMANAS INTENTANDOLO Y NO ENCUENTRO NI EJEMPLOS POR INTERNET....

aqui facilito un video del tema es una practica que hice de otro que vi en internet y con paciencia logre el mismo resultado.........mi fallo usaba la version de godot4,2 y este video solo funciona si se usa godot3 en la version 3 recalco version 3.5.3 estable


extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



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

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





#func _on_Timer_timeout():

#spawn_ProjCopies()


func _input(event):

if event is InputEventMouseButton:

if event.button_index == BUTTON_LEFT:

spawn_ProjCopies()



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

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

EXPLICACION: AQUI FUNCIONA PRESIONANDO BOTON IZQUIERDO DEL MOUSE

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







extends Spatial



# Declare member variables here. Examples:

# var a = 2

# var b = "text"



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

#func _ready():

#var Projectile = load("res://Projectile.tscn")

#var ProjCopies = Projectile.instance()

#add_child(ProjCopies)

#pass # Replace with function body.




#func _process(delta):

#pass

func spawn_ProjCopies():

var Projectile = load("res://Projectile.tscn")

var ProjCopies = Projectile.instance()

add_child(ProjCopies)





#func _on_Timer_timeout():

#spawn_ProjCopies()


func _input(event):

if event is InputEventKey:

if event.scancode == KEY_A:

spawn_ProjCopies()




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

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

EXPLICACION: AQUI FUNCIONA PRESIONANDO LETRA "A" DEL TECLADO

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




jueves, 25 de enero de 2024

https://gamejolt.com/@paco415/games;

😁😀😂😃😄😎😌😋😊😉😈😇😆😅😏😐😑😒😓

128 GAMES DE ESTE BLOG 

😁😀😂😃😄😎😌😋😊😉😈😇😆😅😏😐😑😒😓

martes, 23 de enero de 2024

Script GDScript para Godot3d 4.2 cuando algo entra en Area3d borra diversos elementos y escala uno y cuando sale provoca 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):

var parent = get_parent()

var Area3DBETA = parent.get_node("Area3DBETA")

#Area3DBETA.queue_free()

get_node("CollisionShape3DBETA").queue_free()

get_node("AMETRALLADOR DE BLENDER PINTADOBETA").queue_free()

get_node ("MeshInstance3DBETA")

scale.y+=5.0


scale.x+=5.2


scale.z+=5.2

pass # Replace with function body.



func _on_area_exited(area):

$AudioStreamPlayer.play()

pass # Replace with function body.


Script en GDScript para godot3d 4.2 , cuando algo entra en un Area3d produce un sonido, cuando algo sale del Area3d se borra su contenido;

 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_exited(area):

queue_free()

pass # Replace with function body.



func _on_area_entered(area):

$"../../AudioStreamPlayer".play()

pass # Replace with function body.

-------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
EXPLICACION:
Entra en Area3d
 algo func _on_area_entered(area):

$"../../AudioStreamPlayer".play()

pass # Replace with function body.

emite sonido.........

Sale algo del Area3d 

func _on_area_exited(area):

queue_free()

pass # Replace with function body.

se borra su contenido.

Como se pone un sonido de musica de fondo en Godot 3d 4.2 que este en bucle y suene una y otra vez?;