Actor follow another actor
ChirpinGames
Member, PRO Posts: 214
Hi all,
I have an actor that is being controlled by the keyboard (left and right) and was wondering if it is possible to attach another actor to it. So this second actor sits slightly above the actor1 and moves when it does?
Any help would be appreciated.
Thanks,
Mark
I have an actor that is being controlled by the keyboard (left and right) and was wondering if it is possible to attach another actor to it. So this second actor sits slightly above the actor1 and moves when it does?
Any help would be appreciated.
Thanks,
Mark
Comments
There is a how-to specifically for that one in the Game Logic section.
What Kind of attribute type should it be? (Boolean, text, integer, real, angle, index)
Confused.... screenshots and detail would help.
Toby
1. When the player moves near close proximity or over the target actor
2. The target condition will change and it will follow the Player (Trail Behind - Attach whatever)
3. Until a condition changes again and the object can be dropped off at another actor like HOME base etc.
A pickup basically.
Any ideas how this can be achieved using the - Move to & Constrain attributes
Toby
The attribute needed to be an 'Integer'
However, now that the objects are following me....once they reach their objective (Player Actor) they stop dead. If I move around they fly after me endlessly which is great if they reach the player they stop and freeze.
Can this be made persistent or loop somehow? --- Read below
EDIT: Figured it out by using a timer to loop the action
T
1. When the player moves near to or close proximity / over the target actor
2. The target condition will change and it will follow the Player (Trail Behind - Attach whatever)
3. Until a condition changes again and the object can be dropped off at another actor like HOME base etc.
A pickup basically.
Any ideas how this can be achieved using the - Move to & Constrain attributes
http://www.gamesalad.com/game/play/7917
Probably a really simple behavior or expression huh.
Assume it would it work the same if the target actor went a different route or flew around the map before dropping-off?
Toby
Game attributes created:
-BusX: Bus's X position (real type)
-BusY: Bus's Y position (real type)
-Carried: number of passengers on the bus (integer)
-TotalDropOff: Total at the drop off to be used as an offset multiplier when passengers are added
The Bus:
-Save its attributes in game attributes as a reference for other actors using Constrain Attribute behaviors.
-Usual movement behaviors
The Wheels:
-Constrain their positions relative to the game attributes mentioned above but with an offset
-Rotate depending on which direction key is pressed.
The Pickup and Dropoff:
-2 different actors with nothing in them
The passengers:
-Actor attributes added:
-->OnBus(Boolean): Is this actor on the bus
-->SeatOffset: Offset on the bus.
-The Pickup rule:
--> When colliding with pickup actor AND
--> When colliding with bus actor AND
--> If not already on the bus(OnBus=false) [very important to prevent endless loops] AND
--> If game.Carried < 3 (max allowed on the bus)
----] Change Attribute: self.OnBus = true
----] Change Attribute: self.Offset = game.Carried
----] Change Attribute: game.Carried = game.Carried + 1
-The movement on the bus rule:
--> If self.OnBus = true
----] Constrain Attribute: self.Position.X = game.BusX -14 + SeatOffset*14 (The '-14' is to start at the far left of the bus)
----] Constrain Attribute: self.Position.Y = game.BusY
-The DropOff rule:
--> If collides with DropOff actor AND
--> If on the bus (self.OnBus = true)
----]Change Attribute: self.Position.X = self.Position.X-15-14*game.TotalDropOff (Filling the drop off from right to left)
----]Change Attribute: game.TotalDropOff = game.TotalDropOff +1
----]Change Attribute: game.Carried = game.Carried -1
----]Change Attribute: OnBus = false
On the drop off, you could go even further and set the position of the drop off actor into game attributes to set where the passengers will position themselves after getting off the bus.
Toby