M
mgast
Guest
SOLVED: The problem was that I forgot I had another class that was a child of oAnimal and parent of oCat/oDog. The nearest instance of oAnimal wasn't oCat or oDog, it was oSmallAnimal.
So like this: oAnimal -> oSmallAnimal -> oCat/oDog
_____________________________________________________________________________
I have an object oAnimal, with its two children oCat and oDog.
I want to see if the player is near either animal, so I do this in player's step:
Now I want to change what happens based on what animal I'm near, something like this:
In my real code, I have too many children to try to get the nearest of each, so I need to be able to find the closest one in a single statement. Once the nearest thing is upcasted to the parent class though, it seems to lose the information of what it used to be.
How do I determine if "nearest" was an oCat or oDog?
Please help!
So like this: oAnimal -> oSmallAnimal -> oCat/oDog
_____________________________________________________________________________
I have an object oAnimal, with its two children oCat and oDog.
I want to see if the player is near either animal, so I do this in player's step:
Code:
var nearest = instance_nearest(x, y, oAnimal);
Code:
switch(nearest.object_index)
{
case(oCat):
break;
case(oDog):
break;
}
How do I determine if "nearest" was an oCat or oDog?
Please help!
Last edited by a moderator: