#Override method not working
1 messages · Page 1 of 1 (latest)
Parent Class code:
{
Debug.Log("Interacting with " + transform.name);
}
When I interact with an object that has the ItemPickup script assigned to it. it performs the function of the base method in the parent class but not the child class
Show how you're calling it
What do you mean?
Where do you call the method?
Not sure how to be more clear about that...
So you only get one log?
yeah
That's not the log from the base method . . .
Again, show where you're calling Interact . . .
the code I have above are the only 2 instances of the method being called
Sounds like you're just not calling it at all probably
That's the method being defined, not called
My update method in the parent class could be messing it up
??
{
if (isFocused && !interacted)
{
float distance = Vector3.Distance(player.position, interactionPoint.position);
if(distance <= interactionRadius)
{
Debug.Log("Interact");
interacted = true;
}
}
}```
yeah this is whats actually being called, so instead of the Debug line here, i would call the Interact method?
You need to actually call Interact() on something
Do you know how to call a method?
If you want it to run
You call Vector3.Distance here in Update. You need to do the same thing with your Interact method . . .
Alright replace the debug line with the Update method call fixed it