@xyz said:
You want to change the value of variables that don't exist? That doesn't make much sense.
Iam trying to short code by not having to create the same functions in player.tscn and enemy.tscn files ( enemy and player variables exist, but they dont share them in my game, execpt when they collide, they share about 3 or 4 vars in( player AreaNode hitBox signal ) )
@Erich_L said:
I'm pretty sure my video will clear some things up, ya just gotta get through the first three parts. I was scolded for not covering signals in it which also might help you a bit so there's a link to signal examples in that vid description.
Ive watched it to end, the final part was a bit confusing for me. But the solution i was looking for might required for the script to have a diferent extension (maybe) one that its only readable and not .gd. So it would only detect errors, once the function its set on .gd script.
There is a solution for the script functions to work in other scripts.
for example
instead of:
class_name fc
static func heathSet(value):
health= value;
having:
class_name fc
static func heathSet(playerVar, value):
playerVar= value;
.....
extends KinematicBody
class_name Player1
var health= 150;
func _ready() -> void:
fc.heathSet (health, 200); #-player 200 health
pass
but this requires having more vars in the functions, and some functions would be impossibly long. Iam not saying this is a solution...
static func objectMove(objectMoveVar, moveSpeed, objectJumpVar, jumpForce, objectGravityVar, gravityValue, objectAccelarationVar, accelarationValue, objectBulletsVar, bulletsValue, objectMagicVar, magicValue):
#do something...
pass