Help with checking actors position against another
MaccaMcgill
Member Posts: 8
Hi All,
I was on game salad a couple of years ago and decided to return! Slowly getting back into things but now working on my windows PC rather than a mac so posting my question under this. I have a scene where I have an actor the user controls, I have other actors spawning off scene and moving across at the top. I want the moving actors to drop when they get within a set distance from the player actor.
I currently have a timer on the player actor to update game attributes for playerx/y position every 0.1 seconds, then on the moving actor check every 0.1 seconds if self.position.x < game.playerx + 50, if so then accelerate downwards but they don't move?
Can anyone give any advice? Thanks
I was on game salad a couple of years ago and decided to return! Slowly getting back into things but now working on my windows PC rather than a mac so posting my question under this. I have a scene where I have an actor the user controls, I have other actors spawning off scene and moving across at the top. I want the moving actors to drop when they get within a set distance from the player actor.
I currently have a timer on the player actor to update game attributes for playerx/y position every 0.1 seconds, then on the moving actor check every 0.1 seconds if self.position.x < game.playerx + 50, if so then accelerate downwards but they don't move?
Can anyone give any advice? Thanks
Comments
create two global attributes:
playerX
playerY
on your player actor, constrain playerX to self.position.x, and playerY to self.position.y
then on your moving actors, create an attribute called distance.
constrain distance to the magnitude of (playerX-self.positionX,playerY-self.positionY).
this should give you the distance from each actor to the player
finally, have a rule that says something like
when self.distance is < 100
do whatever
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
I tried exactly what you said but It's not working. What I did is as follows:
Game Attributes (both integers)
PlayerX
PlayerY
Player Actor:
Constrain attribute game.PlayerX to self.position.x
Constrain attribute game.PlayerY to self.position.y
Moving Actor:
Spawns and moves across the screen right to left.
Attribute distance (integer)
Constrain self.distance to magnitude(game.PlayerX - self.position.x, game.PlayerY - self.Position.y)
Rule if self.distance < 50
then accelerate 270 relative to scene with acceleration 150.
However, the moving actor will just move right to left on screen and not drop. Where did I go wrong?
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left