I have a little problem that has me stumped at the moment.
I have a Autoload class file I created with 2 functions:
extends Node
class_name boat
var ent #(scene)
var stage
var speed = .1
var pathNum
var lookAtpiv
func startNewBoat(spawnpoint):
var ent = cache.cache_boat.instance()
ent.translation =Spawnpoint.translation
lookAtpiv = Global.pathNode(1,1)
func processBoat(delta):
if stage == 1:
var target_position = lookAtpiv.transform.origin
ent.look_at(target_position, Vector3.UP)
Okay, I call the creation from my main code:
var bo = boat.new()
bo.startNewBoat(b.randomINT(1, ShipSpawnPointCount ))
boat_list.append(bo)
Everything is good, it creates the entity and positions it as it should.
But further down the logic trail I go to call the processBoat() function from the Class and the ent = NULL.
for boat in boat_list:
boat.processBoat(delta)
Error : Invalid call. Nonexistent function 'look_at' in base 'Nil'.
The other values, stage, speed etc.. are all in the class container, just NULL reference to the node. The looAtpiv reference is fine, it's NULLs on the ent, which i created in the StartNewBoat() process.