sábado, 31 de agosto de 2024

GDScript diversos movimientos para con mouse y su rueda y sus botones y para teclas del pc; muevo una camara a capricho;

 extends MeshInstance3D


var is_rotating = false

var is_rotating2 = false

var is_rotating3 = false

var is_rotating4 = false


var speed = 11  # Adjust the speed as needed

var delta = 0.009

var delta2 = 0.009

var delta3 = 0.009

var delta4 = 0.0002

var delta5 = 0.0002

var delta6 = 0.09

var delta7 = 0.09



func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:

is_rotating = true

else:

is_rotating = false


if event.pressed and event.button_index == 2:

is_rotating2 = true

else:

is_rotating2 = false


if event.pressed and event.button_index == 3:

is_rotating3 = true

else:

is_rotating3 = false


if event.button_index == 3 and not event.pressed:

is_rotating4 = true

else:

is_rotating4 = false

if event.pressed and event.is_action("mouse_rueda_arriba"):

rotate_x(-0.04)

translate(Vector3( 0, -speed * delta6,0))  # Move forward

#translate(Vector3(0, 0, speed * delta))  # Move forward

if event.pressed and event.is_action("mouse_rueda_avajo"):

rotate_x(0.04)

translate(Vector3( 0, speed * delta7,0))  # Move forward

#translate(Vector3( 0, 0,-speed * delta))  # Move forward


if event is InputEventKey:

#if event.pressed and event.scancode == KEY_P:

if event.pressed and event.is_action("GRUADIRECCIONDERECHA-I-"):

translate(Vector3(-speed * delta, 0, 0))  # Move forward


if event.pressed and event.is_action("GRUADIRECCIONIZQUIERDA-U-"):

translate(Vector3(speed * delta2, 0, 0))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONALANTE-J-"):

translate(Vector3( 0, 0, speed * delta))  # Move forward


if event.pressed and event.is_action("GRUADIRECCIONATRAS-K-"):

translate(Vector3( 0, 0, -speed * delta))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONARRIBA-O-"):

translate(Vector3( 0, speed * delta5,0))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONABAJO-P-"):

translate(Vector3( 0, -speed * delta5,0))  # Move forward

if event.pressed and event.is_action("OOPARAINCLINACIONIZQUIERDA"):

rotate_z(0.04)


if event.pressed and event.is_action("PPPARAINCLINACIONDERECHA"):

rotate_z(-0.04)




func _process(delta: float) -> void:

if is_rotating:

rotate_y(0.009)


if is_rotating2:

rotate_y(-0.009)


if is_rotating3:

rotate_x(-0.0009)


if is_rotating4:

rotate_x(0.0009)


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

EXPLICACION:  

MOVER NIÑO -"W"-"A"-"S"-"D" --- "BOTON DEL RATON IZQUIERDO"-¡¡NIÑO MUERDE!!  Y GIRA IZQUIERDA CAMARA ,"BOTON DERECHO"¡¡NIÑO MUERDE!!  Y  GIRA DERECHA CAMARA ,


"RUEDA DEL RATON"  HACERCA ALEJA CAMARA.

 MOVER LA CAMARA -"U"-"I"-"J"-"K"-

 INCLINACION DE CAMARA-"O"-"P"



El script hace todos estos movimientos para mover un MeshInstance3D que contiene una camara, excepto los del texto de color azul que funcionan en otro script que mueve un CharacterBody3D este mueve al player y el player contiene el MeshInstance3D que contiene una camara,

CharacterBody3D es el padre y este un hijo el MeshInstance3D que contiene una camara,

viernes, 30 de agosto de 2024

GDScript activa una animacion con boton izquierdo del raton y tambien con el derecho;

 extends Node3D


var animacion_actual = "Default simplifiedAction"


func _ready() -> void:

# Reproduce la animación principal en bucle

$AnimationPlayer.play("Default simplifiedAction", -1)


func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:

# Pausa la animación principal y encola la secundaria

$AnimationPlayer.stop()

$AnimationPlayer.play("Default simplified|INFLACABEZA")


elif event.button_index == 1 and not event.pressed:

# Reanuda la animación principal

$AnimationPlayer.play("Default simplifiedAction", -1)






if event.pressed and event.button_index == 2:

# Pausa la animación principal y encola la secundaria

$AnimationPlayer.stop()

$AnimationPlayer.play("Default simplified|INFLACABEZA")


elif event.button_index == 1 and not event.pressed:

# Reanuda la animación principal

$AnimationPlayer.play("Default simplifiedAction", -1)

GDScript dispara y ataca tanto con boton izquierdo del raton como con el derecho;

 extends Area3D


var Bullet = preload("res://PERSONAJES/CAVEZA NIÑO MONSTRUO ATACANDO/caveza_ataca.tscn")

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

func _ready() -> void:

pass # Replace with function body.



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

func _process(delta: float) -> void:

pass




func _input(event):


if event is InputEventMouseButton:




if event.button_index == 1 and event.pressed :


var bullet = Bullet.instantiate()



add_child(bullet)




if event is InputEventMouseButton:




if event.button_index == 2 and event.pressed :


var bullet = Bullet.instantiate()



add_child(bullet)

miércoles, 28 de agosto de 2024

GDScript, movimientos y giros por mouse y teclado, presion de teclas de botones del mouse y de rotacion de su rueda;

 extends MeshInstance3D


var is_rotating = false

var is_rotating2 = false

var is_rotating3 = false

var is_rotating4 = false


var speed = 11  # Adjust the speed as needed

var delta = 0.009

var delta2 = 0.009

var delta3 = 0.009

var delta4 = 0.0002

var delta5 = 0.0002

var delta6 = 0.19

var delta7 = 0.19



func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:

is_rotating = true

else:

is_rotating = false


if event.pressed and event.button_index == 2:

is_rotating2 = true

else:

is_rotating2 = false


if event.pressed and event.button_index == 3:

is_rotating3 = true

else:

is_rotating3 = false


if event.button_index == 3 and not event.pressed:

is_rotating4 = true

else:

is_rotating4 = false

if event.pressed and event.is_action("mouse_rueda_arriba"):

translate(Vector3( 0, -speed * delta6,0))  # Move forward

if event.pressed and event.is_action("mouse_rueda_avajo"):

translate(Vector3( 0, speed * delta7,0))  # Move forward


if event is InputEventKey:

#if event.pressed and event.scancode == KEY_P:

if event.pressed and event.is_action("GRUADIRECCIONDERECHA-I-"):

translate(Vector3(-speed * delta, 0, 0))  # Move forward


if event.pressed and event.is_action("GRUADIRECCIONIZQUIERDA-U-"):

translate(Vector3(speed * delta2, 0, 0))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONALANTE-J-"):

translate(Vector3( 0, 0, speed * delta))  # Move forward


if event.pressed and event.is_action("GRUADIRECCIONATRAS-K-"):

translate(Vector3( 0, 0, -speed * delta))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONARRIBA-O-"):

translate(Vector3( 0, speed * delta5,0))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONABAJO-P-"):

translate(Vector3( 0, -speed * delta5,0))  # Move forward



func _process(delta: float) -> void:

if is_rotating:

rotate_y(0.0009)


if is_rotating2:

rotate_y(-0.0009)


if is_rotating3:

rotate_x(-0.0009)


if is_rotating4:

rotate_x(0.0009)

martes, 27 de agosto de 2024

Un personaje camina y al presionar boton del mouse hace otra animacion mientras esta presionado, al soltar sigue la de caminar;

 extends Node3D


var animacion_actual = "Default simplifiedAction"


func _ready() -> void:

# Reproduce la animación principal en bucle

$AnimationPlayer.play("Default simplifiedAction", -1)


func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:

# Pausa la animación principal y encola la secundaria

$AnimationPlayer.stop()

$AnimationPlayer.play("Default simplified|INFLACABEZA")


elif event.button_index == 1 and not event.pressed:

# Reanuda la animación principal

$AnimationPlayer.play("Default simplifiedAction", -1)


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

----------------------ejemplo 2ª------------------- en este hace otras animacion despues de la primera aunque no lo practique la de arriba si que funciona en Godot4.3---------( ACLARACION LA ANIMACION DE CAMINAR A DE ESTAR EN MODO LOOP DESDE DONDE MANIPULAMOS LAS ANIMACIONES EN EL SCRIPT NO ESTA REFLEJADO)-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




extends Node3D


func _ready() -> void:

    $AnimationPlayer.play("Default simplifiedAction", -1)


func _input(event):

    if event is InputEventMouseButton:

        if event.pressed and event.button_index == 1:

            # Pausa la animación principal y encola la secundaria

            $AnimationPlayer.stop()

            $AnimationPlayer.queue("Default simplified|INFLACABEZA")

            $AnimationPlayer.queue("OtraAnimacion")  # Se reproducirá después de la anterior

domingo, 25 de agosto de 2024

Para instanciar un proyectil con Godot 4.3 script GDScript, al presionar boton izquierdo del raton;

 extends Area3D


var Bullet = preload("res://PERSONAJES/CAVEZA NIÑO MONSTRUO ATACANDO/caveza_ataca.tscn")

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

func _ready() -> void:

pass # Replace with function body.



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

func _process(delta: float) -> void:

pass




func _input(event):


if event is InputEventMouseButton:




if event.button_index == 1 and event.pressed :


var bullet = Bullet.instantiate()



add_child(bullet)

Para godot 4.3 GDScript ejecuta animacion, hace rotaciones en ejes "y""z""x", tambien borra el nodo a los 2:50 segundos;

 extends Node3D


# Time elapsed since the node entered the scene

var time_elapsed = 0.0


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

func _ready() -> void:

$AnimationPlayer.play("Default simplified|ATACA")


func _process(delta: float) -> void:

rotate_y(0.02)

rotate_x(0.0018)

rotate_z(0.0018)

# Update elapsed time

time_elapsed += delta


# Queue free the node after 2 seconds

if time_elapsed >= 2.50:

queue_free()

GDScript combinacion de movimientos por raton botones y por teclas del pc;

 extends MeshInstance3D


var is_rotating = false

var is_rotating2 = false

var is_rotating3 = false

var is_rotating4 = false


var speed = 11  # Adjust the speed as needed

var delta = 0.009

var delta2 = 0.009

var delta3 = 0.009

var delta4 = 0.009

var delta5 = 0.022





func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:

is_rotating = true

else:

is_rotating = false


if event.pressed and event.button_index == 2:

is_rotating2 = true

else:

is_rotating2 = false


if event.pressed and event.button_index == 3:

is_rotating3 = true

else:

is_rotating3 = false


if event.button_index == 3 and not event.pressed:

is_rotating4 = true

else:

is_rotating4 = false


if event is InputEventKey:

#if event.pressed and event.scancode == KEY_P:

if event.pressed and event.is_action("GRUADIRECCIONDERECHA-I-"):

translate(Vector3(speed * delta, 0, 0))  # Move forward


if event.pressed and event.is_action("GRUADIRECCIONIZQUIERDA-U-"):

translate(Vector3(-speed * delta2, 0, 0))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONALANTE-J-"):

translate(Vector3( 0, 0, speed * delta))  # Move forward


if event.pressed and event.is_action("GRUADIRECCIONATRAS-K-"):

translate(Vector3( 0, 0, -speed * delta))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONARRIBA-O-"):

translate(Vector3( 0, speed * delta5,0))  # Move forward

if event.pressed and event.is_action("GRUADIRECCIONABAJO-P-"):

translate(Vector3( 0, -speed * delta5,0))  # Move forward


func _process(delta: float) -> void:

if is_rotating:

rotate_y(0.009)


if is_rotating2:

rotate_y(-0.009)


if is_rotating3:

rotate_x(-0.0009)


if is_rotating4:

rotate_x(0.0009)


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

Explicacion: forma efectiva de mover un objeto que contiene la camara para visualizar desde muchos angulos mientras se juega, una viga transparente que en un extremo contiene la camara que tiene el player, el player es el padre pero con este script solo controlamos esa viga un MeshInstance3D, conseguimos que rote desde el centro en su eje "Y"  presionando boton izquierdo del raton , al mantener presionado hace el giro, si se presiona el derecho hace el giro al reves, tambien e conseguido que al presionar la rueda del raton se gire en el eje "X", al soltar gira en el eje "X" al reves y para detener el giro de a de pulsar cualquier otra tecla, por que el script al presionar se escribe asi.....y al soltar ....bueno lo podeis ver esta en verde el detalle

if event.pressed and event.button_index == 3:

is_rotating3 = true

else:

is_rotating3 = false


if event.button_index == 3 and not event.pressed:

is_rotating4 = true

else:

is_rotating4 = false



siguiendo la explicacion, eso es en lo referente al raton, para que el script funcione con teclas del pc ....en este caso hay que asignar las teclas que queremos utilizar para eso desde godot hay que dirijirse a....proyecto y desde hay...configuracion del proyecto ....desde hay mapa de entrada.....desde hay añadir nueva accion  ...ponerle un nombre....en el ejemplo     if event.pressed and event.is_action("GRUADIRECCIONIZQUIERDA-U-"):             esta accion funciona al presionar tecla"u".......................yo en principio queria hacerlo directamente presionando la tecla "u" pero solo lo e consegiodo con esta forma de trabajar Godot 4.3    en la 4.2 supongo funcionara de la misma forma.........tambien e aprendido el tema concepto de "var"    

en el ejemplo  var delta4 = 0.009

                        var delta5 = 0.022


añadiendo propiedades personalizadas a la velocidad de movimientos de los delta que me interesaban alterar.......La IA me a yudado a prender y entender conceptos de programacion de GDScript, creo que es un metodo muy bueno, yo de programacion apenas se hacer nada y me cuesta muchisimo esfuerzo, pero al final si algo te gusta pues sacas provecho.

sábado, 24 de agosto de 2024

Rotar un MeshInstance3D con el raton en eje"y" y en eje "x" mediante GDScript;

extends MeshInstance3D


var is_rotating = false

var is_rotating2 = false

var is_rotating3 = false

var is_rotating4 = false


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

func _ready() -> void:

pass  # Replace with function body.




func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:

is_rotating = true

else:

is_rotating = false

if event is InputEventMouseButton:

if event.pressed and event.button_index == 2:

is_rotating2 = true

else:

is_rotating2 = false

if event is InputEventMouseButton:

if event.pressed and event.button_index == 3:

is_rotating3 = true

else:

is_rotating3 = false




if event is InputEventMouseButton:

if event.button_index == 3 and not event.pressed:

is_rotating4 = true

else:

is_rotating4 = false




func _process(delta: float) -> void:

if is_rotating:

rotate_y(0.009)

if is_rotating2:

rotate_y(-0.0009)

if is_rotating3:

rotate_x(-0.0009)

if is_rotating4:

rotate_x(0.0009)




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

Explicacion: Con este script giro hacia la izquierda un objeto MeshInstance3D en su eje "Y" presionando boton izquierdo, si presiono derecho gira a la derecha sobre si mismo mientras mantengo presionado, y si presiono boton central del raton gira en el eje "X" todo fluidamente, si suelto el boton central gira al contrario del eje "X"....y no para asta que vuelvo a presionar algun boton del raton........

Girar fluidamente y constantemente al presionar botones del raton; con GDScript;

 extends MeshInstance3D


var is_rotating = false

var is_rotating2 = false


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

func _ready() -> void:

pass  # Replace with function body.




func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:

is_rotating = true

else:

is_rotating = false

if event is InputEventMouseButton:

if event.pressed and event.button_index == 2:

is_rotating2 = true

else:

is_rotating2 = false



func _process(delta: float) -> void:

if is_rotating:

rotate_y(0.0009)

if is_rotating2:

rotate_y(-0.0009)




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

En su eje "y" un MeshInstance3D un cubo en forma de viga que sujeta una camara en un extremo, hacemos que gire presionando botones del mouse..........

Al presionar el boton izquierdo del raton, gira suavemente y constantemente un MeshInstance3D en su eje "Y"; mientras se presiona; al soltar se detiene;

extends MeshInstance3D


var is_rotating = false


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

func _ready() -> void:

pass  # Replace with function body.




func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:

is_rotating = true

else:

is_rotating = false


func _process(delta: float) -> void:

if is_rotating:

rotate_y(0.0009)



Al presionar boton izquierdo del raton un MeshInstance3D da un giro en eje "Y", con GDScript;

 extends MeshInstance3D


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

func _ready() -> void:

pass  # Replace with function body.


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

func _process(delta: float) -> void:

pass  # Replace with function body.


func _input(event):

if event is InputEventMouseButton:

if event.pressed and event.button_index == 1:  # Botón izquierdo del ratón

rotate_y(0.9)

jueves, 22 de agosto de 2024

viernes, 16 de agosto de 2024

Para Godot 4.3 GDScript para hacer disparos automaticos cada 1 segundo instanciando un proyectil;

 extends Area3D


var Bullet = preload("res://PROYECTILARMADETIAYSIMILAR/rigid_body_3d BOLO.tscn")

var timer = Timer.new()

var tiempo_disparo = 1.0  # Tiempo entre disparos en segundos


func _ready():

add_child(timer)

timer.timeout.connect(_on_timer_timeout)

timer.start(tiempo_disparo)


func _on_timer_timeout():

var bullet = Bullet.instantiate()

add_child(bullet)

miércoles, 14 de agosto de 2024

Como con GDScript avanzo un personaje u otro objeto y al chocar gira y sigue avanzando;

 extends Area3D

var score = 0

var speed = 0.1  # Unidades por segundo

var tiempo_transcurrido = 0.0  # Tiempo en segundos


# Función que se ejecuta en cada frame

func _process(delta):

# Calcular movimiento basado en la velocidad y el tiempo delta

#var movimiento = Vector3(0,speed * delta,  0)#ORIGINAL

var movimiento = Vector3(0,0,speed * delta)#MODIFICADO


# Aplicar el movimiento a la posición del nodo

translate(movimiento)



# Actualizar el tiempo transcurrido

tiempo_transcurrido += delta



func _on_area_entered(area):

rotate_y(25.02)

pass # Replace with function body.


martes, 13 de agosto de 2024

Manipular la malla de personajes con blender;



Hace tiempo me  estreso cuando modelo con blender personajes y al manipular la malla no hay forma de hacerlo, porque se me van las opciones de seleccionarla y manipularla, en esta captura de video arregle el problema........
 

lunes, 12 de agosto de 2024

Animar personaje con blender;

 creo que con esfuerzo y mucha practica se pueden hacer animaciones manualmente para hacer juegos, y a la larga con mas facilidad y personalidad que usando programas o descargando animaciones ya construidas, bueno hay estoy, soy Indie, no doy a vasto e de saber de todo e de hacer de todo, programar en GDScript, pintar y texturizar, iluminar escenarios, construirlos, hacer guiones y pensar ideas, subir juegos a plataformas webs especializadas, y ahora estoy obsesionado con la animacion y hacer scripts que me la agan funcionar a la perfeccion, se que tengo para años todabia, no se acaba nunca de aprender...

I think that with effort and a lot of practice you can make animations manually to make games, and in the long run with more ease and personality than using programs or downloading already built animations, well here I am, I'm Indie, I don't give a lot of knowledge of everything and from doing everything, programming in GDScript, painting and texturing, lighting scenarios, building them, writing scripts and thinking of ideas, uploading games to specialized web platforms, and now I am obsessed with animation and making scripts that make it work perfectly, I know I still have years to go, learning never ends...


lunes, 5 de agosto de 2024

CollisionShape3D script gdscript para escalar aleatoria y constantemente;

 extends CollisionShape3D


var escala_minima = 0.25  # Tamaño mínimo de escala

var escala_maxima = 1.0  # Tamaño máximo de escala

var tiempo_cambio_escala = 1.0  # Tiempo en segundos entre cambios de escala

var tiempo_transcurrido = 0.0  # Tiempo transcurrido desde el último cambio


func _process(delta):

tiempo_transcurrido += delta


if tiempo_transcurrido >= tiempo_cambio_escala:

tiempo_transcurrido = 0.0


var nueva_escala = Vector3(randf_range(escala_minima, escala_maxima),

  randf_range(escala_minima, escala_maxima),

  randf_range(escala_minima, escala_maxima))


scale = nueva_escala

domingo, 4 de agosto de 2024

GDScript para Godot 4.2, muy simple activa una animacion constante y ademas borra el nodo transcurridos unos 16 segundos;

 extends Node3D


var tiempo_transcurrido = 0.0


# Llamado cuando el nodo entra en el árbol de escena por primera vez.

func _ready():

$AnimationPlayer.play("GESTICULACION")


# Llamado cada cuadro. 'delta' es el tiempo transcurrido desde el cuadro anterior.

func _process(delta):

tiempo_transcurrido += delta


if tiempo_transcurrido >= 16.0:

queue_free()  # Elimina el nodo de la escena