I'm working on a basic game and trying to do steering algorithms and my problem I believe is routed in inheritance of classes.
So basically I have a class called GameplayObjects which have some variables like speed, velocity, etc... I'm now trying to create a class called Steering which is derived from GameplayObjects so I have access to the objects speed and stuff. Now my problem comes in when trying to write the member functions of steering because in order to calculate the needed vectors for the steering I'm using two different GameplayObjects.
So for instance for a seek function I need to subtract the target and source positions but can't get it to work, I've tried everything I can think of like making Getfunctions inside of GameplayObjects to return position but still got errors.
so basically here's what I've tried with no luck....
void Steering::seek (GameplayObjects source, GameplayObjects target)
{
SteeringVector = target.position - source.position;
SteeringVector = *target->Getposition - *source->Getposition; //and yes I changed the declaration of the function so that source and target are pointers
}
So I guess the question is how do I pass in to GameplayObjects and access their respective attributes like speed, position, rotation, velocity, etc.. Its been a while since I've done coding I know this has to be a simple solution but I just cant think of it....