Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lasthy |
I have a script to create physical items using a resource as a base. The code to generate the item so the player can pick up is:
tool
class_name WorldItem
extends Spatial
export (Resource) var item setget set_item
export (int) var quantity = 1
export (Enums.interaction_type) var interactionType
onready var interactionSprite = $InteractionSprite
func set_item(resource):
if resource != item and resource != null:
generate(resource, quantity)
else:
item = null
$Sprite3D.texture = null
func generate(i, q):
item = i
item.generate()
quantity = q
display()
The generate method that the item call would be used to generate random stats like attack, critical hit rate, etc, and the script looks like:
extends Weapon
class_name MeeleeWeapon
export(Vector3) var hitbox_size: Vector3
export(Vector3) var hitbox_offset: Vector3
func generate():
print("asioasi")
But, when I drag the resource of the item, it just says that it is a non existent function, in base Resource (the heritance is like: Resource <= Item <= Equipment <= Weapon <= MeeleeWeapon)
Anyone have any idea of what it could be?