distance enabled/disabled actors

Talk about making games.

distance enabled/disabled actors

Postby rconnor » Mon Apr 09, 2007 3:09 pm

Good Day to All!

Problem:

I have 4 actors that need to be enabled/disabled according to their
distance from the actorTarget.

I have actors1-4 out of view. Each one is created..., "Create Actor" (button down) to a specific x,y starting point. "Actor Control - Create at Start Up" is set to "No" on actors1-4.

Each actors1-4 are to be dragged and dropped pre-determined distances to the actorTarget taking turns according to how far they are from actorTarget. The actor that is the longest distance from actorTarget is to be enabled.

For Example, actor1 & actor2 are created and players 1 & 2 are taking turns to move closer to actorTarget. The following script works fine to the point in which actor1 and/or actor2 get closer to actorTarget than the remaining actors(3-4), out of view. This has me stumped because "Actor Control - Create at Start Up" is set to "No" on actors1-4.

The following script would be assigned to each actor accordingly on "Move Finish - Script Editor" and Global vars?

int d1;
int d2;
int d3;
int d4;

d1 = distance(actor1.x, actor1.y, actorTarget.x, actorTarget.y);
d2 = distance(actor2.x, actor2.y, actorTarget.x, actorTarget.y);
d3 = distance(actor3.x, actor3.y, actorTarget.x, actorTarget.y);
d4 = distance(actor4.x, actor4.y, actorTarget.x, actorTarget.y);


if (d1 >= d2 && d1 >= d3 && d1 >= d4)

{
EventEnable("actor1", EVENTALL);

EventDisable("actor2", EVENTALL);
EventDisable("actor3", EVENTALL);
EventDisable("actor4", EVENTALL);
}

else if (d1 < d2 || d1 < d3 || d1 < d4)

EventDisable("actor1", EVENTALL);




Help is most appreciated!

TIA
Rob
rconnor
 
Posts: 11
Joined: Sun Jan 07, 2007 5:14 pm
Score: 0 Give a positive score

Postby Sgt. Sparky » Mon Apr 09, 2007 6:36 pm

the draw actor event would work best for that,
but I am really confused about what you are trying to do and what you are having a problem with.

I think distance is read only,
but if it is working, great!
:)

is there any other way you can type this out so I can understand your problem better? :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

re:

Postby rconnor » Mon Apr 09, 2007 8:52 pm

Hey Sarge,

Yeah, it works. Let’s say I’m creating a multi-player golf game. Up to 4 players can play at once, taking turns. Only the actor/player who is the greatest distance away from the flag/pin should be enabled. Here’s the rub. If there are only 3 players playing, actor4 is a factor in the game play even when it has not yet been created. Which means that it disables all actors/players who are closer to the flag/pin.

This has me stumped because "Actor Control - Create at Start Up" is set to "No” on all the actors including actor4.

Whew! Hope that makes sense!
rconnor
 
Posts: 11
Joined: Sun Jan 07, 2007 5:14 pm
Score: 0 Give a positive score

Postby Sgt. Sparky » Mon Apr 09, 2007 9:04 pm

okay,
you must use
Code: Select all
if(ActorCount("Player_4") == 1)
{
   ExecuteAction;
}


or you must use
Code: Select all
if(ActorCount("Player_4") == 1)ExecuteAction;

:D
I hope that helps :)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Re: re:

Postby makslane » Mon Apr 09, 2007 10:44 pm

rconnor wrote:If there are only 3 players playing, actor4 is a factor in the game play even when it has not yet been created.


May be a bug. Can you send me the game?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby rconnor » Tue Apr 10, 2007 1:57 pm

Thanks Sarge. I'll give it a try after Makslane takes a look at it.
rconnor
 
Posts: 11
Joined: Sun Jan 07, 2007 5:14 pm
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron