Jump to content
TheConceptBoy

Help figuring out creating custom Actors C++

Recommended Posts

cZombie()? How does that fix the damn thing? I saw that c prefix in your own BasrActor file you posted but I figured that was just you personal naming convention. Is this some sort of a special modifier?

Share this post


Link to post

Unfortunately it wasn't that simple.  I don't know how it happens but sometimes the file gets corrupted.  I opened the header file in a Hex Editor so I could see every byte of info and found these funny symbols (circled in red).  After removing those it compiled fine :D

Before.thumb.png.edc1ea4ead7e6031a1ec1000eef798d7.png

Share this post


Link to post

Ah, great. So there was literally no way an inexperienced C++ programmer would have ever been able to guess that one. 

Well at least I know now.

 

Any ideas if it was VS that caused it? Or perhaps the internet browser is designed to add scramble to potentially harmful files? Notice how the cpp file transfered ok but the .h file had all sort of a mess added to it's suffix?

Share this post


Link to post

I'd say it was VS.  A few years ago I had a similar issue.  I think how I solved it was I just deleted all the white spaces between the functions and the error was solved.  Luckily it wasn't a big class.  Another thing I've noticed with VS, sometimes it will say you have an error but it will compile and run fine.  I think this is the intellisense kicking the bucket - the only way I've found to fix that is to restart VS.

 

Share this post


Link to post

Can we use an alternative to VS? Do we have to use VS? 

You seem to also be able to run the code from within the LW Level Editor. And the Built in code editor can also open cpp and h files

Share this post


Link to post

Now that I've gotten a single instance of the zombie class spawned, which, now that I've gotten a hang of it, was pretty damn straight forward.

Thank you for the help and patience btw

1) Creating a proverbial horder of zombie instances would require creating an array based on the actor entity class and storing all the zombies in that array?

Share this post


Link to post
35 minutes ago, TheConceptBoy said:

Can we use an alternative to VS? Do we have to use VS? 

VS has a lot of good debugging tools.  Personally, despite some of the things that can go wrong with it, I would use it over the internal editor.

29 minutes ago, TheConceptBoy said:

Thank you for the help and patience btw

Welcome :D

29 minutes ago, TheConceptBoy said:

Now that I've gotten a single instance of the zombie class spawned, which, now that I've gotten a hang of it, was pretty damn straight forward.

Thank you for the help and patience btw

1) Creating a proverbial horder of zombie instances would require creating an array based on the actor entity class and storing all the zombies in that array?

How I would go about it is load 100 zombies in an Entity* array.  Then assign each entity a ZombieActor class.  Inside your ZombieActor class you make it control each entity.  E.g. In UpdateWorld() you would check the distance to the player, if the payer is close you make it attack.

Share this post


Link to post
8 hours ago, Lethal Raptor Games said:

How I would go about it is load 100 zombies in an Entity* array.  Then assign each entity a ZombieActor class.  Inside your ZombieActor class you make it control each entity.  E.g. In UpdateWorld() you would check the distance to the player, if the payer is close you make it attack.

Ah, so far the array created with the Entity class method was the correct procedure. So that part lines with with the standard C++ game dev procedure. 

 

And I take it, then you can address each zombie in that array by using it's id in the entity array slots then?

Share this post


Link to post

Oh and from this point on, we are loading models and meshes inside the zombie actor class on Attach() right? When we detach, I believe I read somewhere that the engine handles removal of created instances automatically? Models. Sounds, Physics, Shapes? 

Share this post


Link to post
5 hours ago, TheConceptBoy said:

Oh and from this point on, we are loading models and meshes inside the zombie actor class on Attach() right? When we detach, I believe I read somewhere that the engine handles removal of created instances automatically? Models. Sounds, Physics, Shapes? 

The best way is to load them outside of the actor class.  Then you attach the actor to each loaded zombie entity.  If you load them in the Attach function you would have to create a separate object (maybe a pivot) and assign the actor class to that pivot so that the actor functions are called.

Share this post


Link to post
4 hours ago, Lethal Raptor Games said:

The best way is to load them outside of the actor class.  Then you attach the actor to each loaded zombie entity.  If you load them in the Attach function you would have to create a separate object (maybe a pivot) and assign the actor class to that pivot so that the actor functions are called.

Really? I figured the whole deal with using the Actors is that you can just handle all the zombie related stuff IN the actual zombie when it's created... like Load the sounds, load the Model, load the animations, textures, materials and what not - everything related to the zombie. Instead it's like you're but a stone throw away from just doing it with your own class and not using Leadwerks Actor.. The hooks are useful though.

 

I know that you should probably only load up the zombie 3D model once and instance it to all the actors. You really don't need to have 40 spawned zombies ALL load the model right? You can probably just Load the model once in the engine and then have the various zombies use that one loaded mode. Am I thinking this right?

 

Say if I load the Model in the main.cpp, can the zombie actor class access the model variables located in the main file? I know I can set the zombie model when I create the zombies in the main.cpp file, but I'd love to be able to just leave ALL zombie related code in the zombie, including the model assignment. 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...