martes, 30 de enero de 2024

Usar LOOD en Godot4.2 reducir poligonos y reducir memoria para fluidez de los juegos en Godot;

Una pelicula vale mas que 1000 palabras, el sistema de LOOD o LOD sirve para reducir los poligonos que dibujan los objetos del juego, personajes, edificios, vegetacion, vehiculos, lo que sea.....cuando estas lejos pocos poligonos poca memoria necesita gana fluidez cuando estas mas cerca mas nitidez y mas poligonos, si se save jugar con la memoria de los desarrollos, importa un pimiento la que tengas en tu pc , .....claro que si puedes tener un buen pc aprobecha , pero es mas saber utilizar la maquina de la que se dispone, yo personalmente estoy muy entusiasmado con Godot quizas no es tan perfeccionista con los resultados pero, si no bas a ser profesional y trabajar para otro.....creo que no tienes nada que perder teniendo en cuenta que godot es totalmente gratuito y que encima hay posibilidares de ganar algo haciendo juegos con el, 

y ahora que empiezo a comprender el tema de instanciar objetos en las escenas con Godot4.2, me boy a poner las botas haciendo virgerias con este estupendo motor de juegos gratuito........Godot.
 

lunes, 29 de enero de 2024

instancia muy simple en godot4.2;

 extends Area3D

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


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


var bullet = Bullet.instantiate()

add_child(bullet)

pass



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

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

extends Area3D

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

func _ready():

pass # Replace with function body.

func _process(delta):

var bullet = Bullet.instantiate()

add_child(bullet)

pass


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

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

otra manera que funciona de instanciar en godot4.2

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

extends Area3D


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


var time = 0

var interval = 1.0  # Time interval between bullet instantiation


func _ready():

pass # Replace with function body.


func _process(delta):

time += delta


if time > interval:

time = 0


var bullet = Bullet.instantiate()

add_child(bullet)

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

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

este de debajo me falla pero creo que es por mi configuracion personalizada de teclas en godot algo que e de solucionar

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

extends Area3D


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


var pressed = false


func _ready():

pass # Replace with function body.


func _input(event):

if event is InputEventKey:

if event.scancode == KEY_SPACE:

if not pressed:

pressed = true

var bullet = Bullet.instantiate()

add_child(bullet)

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

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

otro ejemplo, con el boton izquierdo del raton me funciona por que lo e configurado desde un principio asignandole esa bariacion de entradas de teclado desde Proyecto---configuracion de proyecto-----

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

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

extends Area3D


var Bullet = preload("res://cubo.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)

------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
otro ejemplo al tocar un trigger
------------------------------------------------------------------------------------------------------


extends Area3D


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


func _ready():

    pass # Replace with function body.


func _physics_process(delta):

    # Check if the player is touching the trigger

    if $Trigger.is_colliding():

        var bullet = Bullet.instantiate()

        add_child(bullet)


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

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

este script que funciona solo aplica una fuerza para lanzar un cubo 

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


extends RigidBody3D



# 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

translate(Vector3(111,0,0) * get_process_delta_time())








extends CharacterBody3D-------para godot4.2 a de tener una camara y solo es para CharacterBody3D-;

 extends CharacterBody3D


const SPEED = 5.0

const JUMP_VELOCITY = 4.5

const FRICTION = 25

const HORIZONTAL_ACCELERATION = 30

const MAX_SPEED=5

# Get the gravity from the project settings to be synced with RigidBody nodes.

var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")


@onready var camera = $Camera3D




func _ready():

Input.mouse_mode=Input.MOUSE_MODE_CAPTURED


func _unhandled_input(event):

if event is InputEventMouseMotion and Input.mouse_mode==Input.MOUSE_MODE_CAPTURED:

rotate_y(-event.relative.x * .005)

camera.rotate_x(-event.relative.y * .005)

camera.rotation.x = clamp(camera.rotation.x, -PI/2, PI/2)


func _unhandled_key_input(event):

if Input.is_action_just_pressed("ui_cancel"):

if Input.mouse_mode==Input.MOUSE_MODE_CAPTURED: 

Input.mouse_mode=Input.MOUSE_MODE_VISIBLE

else:

Input.mouse_mode=Input.MOUSE_MODE_CAPTURED


func _physics_process(delta):

# Add the gravity.

if not is_on_floor():

velocity.y -= gravity * delta


# Handle Jump.

if Input.is_action_just_pressed("ui_accept") and is_on_floor() and Input.mouse_mode==Input.MOUSE_MODE_CAPTURED:

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 = Vector3.ZERO

var movetoward = Vector3.ZERO

input_dir.x = Input.get_vector("move_left", "move_right", "move_forward", "move_backward").x

input_dir.y = Input.get_vector("move_left", "move_right", "move_forward", "move_backward").y

input_dir=input_dir.normalized()

var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()

direction *= SPEED

velocity.x = move_toward(velocity.x,direction.x, HORIZONTAL_ACCELERATION * delta)

velocity.z = move_toward(velocity.z,direction.z, HORIZONTAL_ACCELERATION * delta)


var angle=5

#rotation_degrees=Vector3(input_dir.normalized().y*angle,rotation_degrees.y,-input_dir.normalized().x*angle)

var t = delta * 6

if Input.mouse_mode==Input.MOUSE_MODE_CAPTURED: 

rotation_degrees=rotation_degrees.lerp(Vector3(input_dir.normalized().y*angle,rotation_degrees.y,-input_dir.normalized().x*angle),t)

move_and_slide()

force_update_transform()


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 

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