Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 718 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to switch control between characters #188590
03/15/08 14:18
03/15/08 14:18
Joined: May 2005
Posts: 97
G
gedimaster Offline OP
Junior Member
gedimaster  Offline OP
Junior Member
G

Joined: May 2005
Posts: 97
hi,

i have 2 entities, i can control the movement of one entity such as walking. but i'd like to switch the control over to the other entity. how can i do that?

can i simply do this?? thanks for any help.



entity_pointer_1 = my;

// say on_key_1

entity_pointer_2 = my;

Re: How to switch control between characters [Re: gedimaster] #188591
03/15/08 15:29
03/15/08 15:29
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Are you using 1 single action in your script and assigning it to both entities?

It is best to create 2 seperate actions for each entity you want to control..

ENTITY* player_1
ENTITY* player_2

Action 1
{
player_1=me;
.....
walking code
}

Action 2
{
player_2=me;
.....
walking code
}

So now you can control each entity individually, depending upon the controls that you assign to them.

Don't forget to assign the right action to the right entity in WED.

Re: How to switch control between characters [Re: DJBMASTER] #188592
03/16/08 16:51
03/16/08 16:51
Joined: May 2005
Posts: 97
G
gedimaster Offline OP
Junior Member
gedimaster  Offline OP
Junior Member
G

Joined: May 2005
Posts: 97
i'd like to use the same action for all entities instead of creating one for each entity.

i only want one entity to be 'active' at all time, it is like switching control from one entity to another.

from your example code, the two entities seem to move together because their pointer is assigned to 'me'. please correct me if i'm wrong.

any sample code that can be run to illustrate the case is greatly appreciated.

Re: How to switch control between characters [Re: gedimaster] #188593
03/16/08 17:10
03/16/08 17:10
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
No, they would not move together because they have different pointers. The ME pointer is an internal engine pointer.

Me just pointers to the current entity the action is assigned to. So if you assign a different pointer to it, eg. player_1, then that entity then has pointer player_1 and not me.

You then can manipulate the entity by referencing player_1.

If you do not want to create an action for each entity then create a different pointer for each entity you want. Then use ent_create to load the model and assign it the pointer like so.

Entity* player_1;
Entity* player_2;

Action move_players
{

player_1 = ent_create("model1.mdl", vector(10,0,0), some_function);
player_2 = ent_create("model2.mdl", vector(20,0,0), some_function);

}

Then you can move each entity by referencing their pointers...

player_1.x = 0;

Finally you will want to switch controls to different entities. Use one big function for that (some_function) and control keys with different pointers.

Hope you get that, pointers aren't the easiest concept in the world, lol.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1