Crystal Space
Welcome, Guest. Please login or register.
September 21, 2014, 09:16:16 am

Login with username, password and session length
Search:     Advanced search
9018 Posts in 2051 Topics by 8494 Members
Latest Member: Onapthanh
* Home Help Search Login Register
+  Crystal Space
|-+  Associate Projects
| |-+  CEL Discussion
| | |-+  How to select an entity and get the entity?
« previous next »
Pages: [1] Print
Author Topic: How to select an entity and get the entity?  (Read 5235 times)
Hilake
Newbie
*
Posts: 27


View Profile Email
« on: July 21, 2005, 03:25:12 am »

hi, all!!
I'm new guy for CEL.

I want to achieve a function for attack ,but how to select a target and get his information such as position and the object of the entity and so on??


Any comment will be welcome!

thanks
Hilake
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: July 21, 2005, 05:36:57 am »

hi, all!!
I'm new guy for CEL.

I want to achieve a function for attack ,but how to select a target and get his information such as position and the object of the entity and so on??


Any comment will be welcome!

thanks
Hilake

You can use the pcmeshsel property class. If you use that then you will get messages in the behaviour that the mesh has been clicked on. Then you can ask the current position from the mesh (pcmesh->GetMesh ()->GetMovable ()->GetFullTransform().GetOrigin()).

Greetings,
Logged
Hilake
Newbie
*
Posts: 27


View Profile Email
« Reply #2 on: July 21, 2005, 10:29:39 am »

Thank you !
But how can I get the entity ,when I select the target?I mean that I want to get the entity when I select the target ,so I can easily control my target!

Maybe the method that I think isn't good !So ,I want to tell you want I want to do ,I hope you can tell the method what can I do.

I want to make my game actor to attack the otherone ,so I must select one target ,and  judge if my game actor can hit the target .So ,how can I do?


hi, all!!
I'm new guy for CEL.

I want to achieve a function for attack ,but how to select a target and get his information such as position and the object of the entity and so on??


Any comment will be welcome!

thanks
Hilake

You can use the pcmeshsel property class. If you use that then you will get messages in the behaviour that the mesh has been clicked on. Then you can ask the current position from the mesh (pcmesh->GetMesh ()->GetMovable ()->GetFullTransform().GetOrigin()).

Greetings,
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: July 21, 2005, 07:31:32 pm »

Thank you !
But how can I get the entity ,when I select the target?I mean that I want to get the entity when I select the target ,so I can easily control my target!

In the message you get from pcmeshsel the entity is given (as the 'entity' parameter). Here is how you can get it in the message handler:

Code:
    iCelEntity* ent = params->GetParameter (pl->FetchStringID (
    "cel.parameter.entity"))->value.ent;

Greetings,
Logged
Hilake
Newbie
*
Posts: 27


View Profile Email
« Reply #4 on: July 23, 2005, 02:54:15 am »

Thanks!
I will try it !
In the message you get from pcmeshsel the entity is given (as the 'entity' parameter). Here is how you can get it in the message handler:

Code:
    iCelEntity* ent = params->GetParameter (pl->FetchStringID (
    "cel.parameter.entity"))->value.ent;

Logged
Hilake
Newbie
*
Posts: 27


View Profile Email
« Reply #5 on: July 26, 2005, 08:10:54 am »

I have another problem.

There have two actor, when one actor want to attack the other. When the actor select the other one, then how to make the two actor know each other. Because when one actor selected by others, he just send message to hisself. How to make the others know his information.



In the message you get from pcmeshsel the entity is given (as the 'entity' parameter). Here is how you can get it in the message handler:

Code:
    iCelEntity* ent = params->GetParameter (pl->FetchStringID (
    "cel.parameter.entity"))->value.ent;

Greetings,
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #6 on: July 27, 2005, 11:40:08 am »

I have another problem.

There have two actor, when one actor want to attack the other. When the actor select the other one, then how to make the two actor know each other. Because when one actor selected by others, he just send message to hisself. How to make the others know his information.


Well that's up to your game logic to control. If you give all entities in your game unique names then you can easily find the entity and the behaviour. You can use normal C++ calls to talk between behaviours/entities in your game.

Greetings,
Logged
Hilake
Newbie
*
Posts: 27


View Profile Email
« Reply #7 on: July 28, 2005, 06:47:44 am »

That's helpful. Thanks!
But I think it's not the best way. For all entities in my game has the unique behaviours. How two make one entity know the other entity's behaviour?


Well that's up to your game logic to control. If you give all entities in your game unique names then you can easily find the entity and the behaviour. You can use normal C++ calls to talk between behaviours/entities in your game.

Greetings,
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #8 on: July 28, 2005, 07:56:03 pm »

That's helpful. Thanks!
But I think it's not the best way. For all entities in my game has the unique behaviours. How two make one entity know the other entity's behaviour?


entity->GetBehaviour(). You can cast that pointer to your own behaviour class.

Greetings,
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.187 seconds with 17 queries.