martes, 7 de mayo de 2024

GDScript, produce disparos con el mouse, rafagas de disparos girando la rueda del mouse; todo rafagas;para disparos de 1 en 1, solamente presionar 1-----if event.button_index == 1 and event.pressed :;

 extends Area3D


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


func _ready():


pass # Replace with function body.



func _input(event):



if event is InputEventMouseButton:


#if event.button_index == 1:

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

var bullet = Bullet.instantiate()



add_child(bullet)


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

para disparos de 1 en 1, sin rafaga, sin que salgan 2 disparos al presionar 1 y soltar 1, solamente presionar 1---------------if event.button_index == 1 and event.pressed :

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

extends Area3D


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


func _ready():


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()



add_child(bullet)


------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
al soltar la presion de la tecla del mouse....
--------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------
extends Area3D

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

func _ready():

pass # Replace with function body.


func _input(event):


if event is InputEventMouseButton:

#if event.button_index == 1 and event.pressed :#AL,PRESIONAR
if event.button_index == 1 and not event.pressed :#AL SOLTAR
#event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
var bullet = Bullet.instantiate()


add_child(bullet)

No hay comentarios:

Publicar un comentario