Hello everyone I am new to this forum.
I'm wondering if it's possible to put two different functions on one mouse button.
for example:
if button number 1 is a rifle with its animations and sound effects.
and if button 2 is an ax with its animations.
What they have in common is the left mouse button, when I press the number 1 button and press the left mouse button to show the animation of the rifle, and when I press the number 2 button and press the left mouse button, I get animation and ax effects.
here is my code:
extends Spatial
class_name Weapon
var add_method = preload("res://Player/Player.gd").new()
var per = preload("res://Player/Axe.gd").new()
if Input.isactionjustpressed("primaryfire"):
if currentammo > 0 and canfire and not reloading:
fire()
anim_player.play("Fire")
if raycast.is_colliding():
var b = bullet.instance()
muzzle.add_child(b)
b.look_at($"../../RayCast".get_collision_point(), Vector3.UP)
b.shoot = true
elif not reloading:
reload()
if Input.is_action_just_pressed("primary_fire"):
per.strikes()
extends Spatial
var add_method = preload("res://Player/Player.gd").new()
func physicsprocess(delta):
if Input.isactionjustpressed("primaryfire"):
axeplayer.play("Axecut")
extends KinematicBody
classname Playerval
export var currentweapon = 0
func weaponselect():
if Input.isactionjustpressed("weapon1"):
currentweapon = 1
elif Input.is_action_just_pressed("weapon2"):
current_weapon = 2
if current_weapon == 1:
weapon1.visible = true
else:
weapon1.visible = false
if current_weapon == 2:
weapon2.visible = true
else:
weapon2.visible = false
issue:
Occurs when I select for example button number 1 and press the left button I get two effects in one the sound of a shot fired from a rifle and the blow of an ax from a tree
If anyone can help me thanks in advance.