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)