Jump to content

Call a custom function on hitinfo entity


ErhanK
 Share

Recommended Posts

Hi. How can i call a custom function on my hitinfo entity?

if (PickResult) {
	if (PickInfo.entity->GetClass() == Entity::ModelClass) {
		if (PickInfo.entity->GetKeyValue("GameObjectType") == "NpcBase") {
			//PickInfo.entity-> ?? ex. GetHurt()
		}
	}
}

 

Link to comment
Share on other sites

I want to call the custom function in a c++ class ... I have one more question. I don't know which is better. I've created a custom actor class. This class creates an entity within itself and attaches itself to it. Should I use this, or should I create an entity, also create a custom actor and then assign that actor to that entity? I gave an example below.

//Header
class EnemyBaseActor : public Actor {
public:
    EnemyBaseActor();
};
//CPP
EnemyBaseActor::EnemyBaseActor(){
    this->entity = Model::Load("Models/Zombie.mdl"); 
    this->entity->SetActor(this);   
}

OR

// In the main ex.
Entity* myEntity = Model::Load("Models/Zombie.mdl");
Actor* zombieActor = new EnemyBaseActor(); //My custom actor.
myEntity->SetActor(zombieActor);
//zombieActor->Release(); // It's doesn't work. So i didn'n write it.

it works in two ways, but which one is right?

Link to comment
Share on other sites

A dynamic cast will return NULL if the conversion is not valid. (A static cast can potentially return an invalid object.) So you might want to also check if the result of the cast is NULL before continuing.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...