miércoles, 6 de noviembre de 2024

Un ejemplo instancia proyectil, y apunta con rueda y con teclas -z-x-; en el mismo GDScript;

 








extends Area3D



var Bullet = preload("res://EL PROTAGONISTA/BALA PROYECTIL/PROYECTIL.tscn")

#var Bullet2 = preload("res://EL PROTAGONISTA/FOGONAZO PISTOLA/cpu_particles_3dfogonazo.tscn")



func _ready() -> void:




pass # Replace with function body.






func _input(event):






if event is InputEventMouseButton:




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



#event.button_index == MOUSE_BUTTON_LEFT and event.pressed:


var bullet = Bullet.instantiate()

#var bullet2 = Bullet2.instantiate()


add_child(bullet)

#add_child(bullet2)


func _unhandled_input(event):

if event is InputEventKey and event.pressed:

if event.keycode == KEY_W:

translate(Vector3(0, 0, 0) * get_process_delta_time())  # Temporary movement (consider physics)


#if event.keycode == KEY_


#apply_impulse(Vector3(0,40,4))#ORIGINAL



if event.keycode == KEY_Z:

rotate_x(0.02)

pass

if event.keycode == KEY_X:

rotate_x(-0.02)

pass

if event is InputEventMouseButton:



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

#if event.action == "mouse_rueda_arriba":

rotate_x(-0.02)

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

#elif event.action == "mouse_rueda_avajo":

rotate_x(0.02)

pass

Rotacion de un MeshInstance3D con "z" "x" y con rotacion de rueda del raton; con mapas de entrada"mouse_rueda_arriba" y "mouse_rueda_avajo";

 extends MeshInstance3D


func _input(event):

# Comprobamos si es un evento de teclado

if event is InputEventKey:

if event.pressed:

if event.keycode == KEY_Z:

rotate_x(0.02)

elif event.keycode == KEY_X:

rotate_x(-0.02)

# Comprobamos si es un evento de acción de entrada

elif event is InputEventAction:

pass

#func _input(event):

if event is InputEventMouseButton:



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

#if event.action == "mouse_rueda_arriba":

rotate_x(-0.02)

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

#elif event.action == "mouse_rueda_avajo":

rotate_x(0.02)

Rotacion de un MeshInstance3D presionando "z" y presionando "x";

 extends MeshInstance3D


func _ready() -> void:


pass # Replace with function body.


func _input(event):



if event is InputEventKey and event.pressed:


if event.keycode == KEY_Z:

rotate_x(0.02)

pass

if event.keycode == KEY_X:

rotate_x(-0.02)

pass