In the meantime, why don’t you start moving Inherited to its rightful place? Then, let’s see if michalis has any suggestions.
Because I know for a fact, he just tells me to continue to RTFM/look in the book he gave me, he’d just say that yet again, because he’s too busy to help me in detail like you do.
Again, I know it’s not personal but it’s just that he’s too busy with other stuff to help absolute beginners like me, like he explained.
Sadly, still the same error even though again, I know I am correct in the syntax and what data type I should use, even after I moved “inherited” to before the variables.
it’s just a question, why do you set Avatar to nil?
I tried doing it without the “begin” and “end” parts, but learned that wasn’t the proper way to start a constructor method.
Therefore, I decided to follow the convention of the TViewMain constructor method
that existed already, and set an arbitrary property to a value.
I tried at first to assign it to an actual object like HumanBase1, which is known
to come with the example, but it wouldn’t accept it so I went with a “nil” value instead,
because the AvatarHiearchy assignmnent would override it with a new avatar in
the end anyway.
The proof I have of that I did the correct way to initalize the instance of a class within a seperate, unrelated class method is using this example, straight from the very top of page 226.
procedure TDateForm.FormCreate(Sender: TObject);
begin
ADay := TDate.Create;
LabelDate.Text := ADay.GetText;
end;
Maybe my issue is that I am using the function as “class.procedure” rather than correctly “unrelated class.property := class.procedure”? That’s my guess.
In this case, I think it’s safe to say that TMyThirdPersonNavigation.HumanBase1 is what I should assign on the left side, cause that’s what avatar I am trying to assign in the first place.
Nope, still the same issue either way. This really stinks, especially cause I know I explicitly defined the class procedure above and referenced it using the correct syntax in the particular section it is objecting to.
Judging by the example, maybe I should omit the parenthesis after the Create, although again that doesn’t make a lot of sense for procedures or methods in general with parameters, cause usually they need something to fill in each space.
However, going by the example from the book it seems to suggest that you don’t actually do anything in parenthesis.
Okay, I was right, it was registering I didn’t give the correct number of parameters when
I passed it off as something with no parameters.
I tried passing off a different component for the creation’s owner, like HumanBase1,
but it tells me even that is unknown identifier which again is plain old ridiculous, because it’s clearly something that’s part of the viewport, and anyone who has
the latest version can verify that by opening the project.
Have you tried using FreeAtStop
?
Okay, I didn’t see your post but instead assigned the component as MyThirdPersonNavigation.HumanBase1, but got an exception violation crash at
that line, so I think it’s cause I didn’t initalize MyThirdPersonNavigation locally, so I will use TMyThirdPersonNavigation instead.
I didn’t think of FreeatStop, but I know I can always Google it and see what it does, and how I should place it. Maybe Google “Pascal how to use FreeatStop”, or is that too generic for this example?
Okay, unfortunately I learned the game engine doesn’t like that either; so I should Google “how to use FreeAtStop in Pascal”?
I tried Googling that specific phrase word for word, but unfortunately can’t seem to find anything using that line verbatim, only slightly related stuff like “Exit” or “Halt”.
It seems like what @michalis advised you to do in the first posts of the previous thread. Take a look.
This is the first result in Google search:
https://castle-engine.io/viewport_and_scenes_from_code
I’m not saying it’s useful, but how did you not find it?
It’s just plain weird, maybe cause I get Bing results every time I Google something on my browser, which is a bug on my end I think I need to fix, but yeah that legitimately didn’t show up on my end.
Unfortunately, there doesn’t seem to be anything at all about “FreeAtStop” verbatim; does it require more room for interpretation, like it won’t pop right up at you but it’s implied?
This is from the previous thread, it’s a reply from Michalis.
procedure TMyView.Start;
var
MyNavigation: TMyThirdPersonNavigation;
begin
inherited;
MyNavigation := TMyThirdPersonNavigation.Create(FreeAtStop);
// adjust any parameters you need:MyNavigation.CameraSpeed := 9;
MyViewport.InsertBack(MyNavigation);
end;
FreeAtStop I imagine means to free the resource when exiting the application or something similar.
As I already told you, in the previous thread there are important clarifications from Michalis. Why don’t you come back and take a look at it?
Now I get that part, and that I also need to insert the navigation into the viewport afterward.
Unfortunately, I get this crash method afterward when I copy it verbatim.
If I know global variables well enough,
I think it is because I didn’t actually define “MyViewport” anywhere in the code, but unfortunately when I tried both “TViewMain” and “ViewMain” for the appropriate variable names (if what the book tells me is right, and it should be! Then ViewMain is most proper, because you access variables of classes in functions and procedures, and not the class itself by convention), it would give me the error that I wasn’t accessing a proper class, like it would say “only class methods, class variables” etc, that error.
I don’t know if you have to put MyThirdPersonNavigation
in the Viewport, it depends on what you are doing. I pasted this piece of code just for reference to FreeAtStop
.
Again, now that you’ve progressed in the study and can understand better, go back to the old thread and read all the answers from the beginning. You could find everything you need there.
Now I understand, I wasn’t actually supposed to paste it verbatim.