Destroy actor when overlap/collide/same Y position... what am I doing wrong??
Ok.. This is really annoying me, and I can't figure it out.
My game is a vertical scroller. A joystick controls the main actor who is "flying" upwards. I have the camera control following this main actor. The main actor is on a scrollable layer. The joystick is on a non-scrollable layer.
I have placed another actor at Y = 0 and X = 160 (center-bottom of scene). This actor is a horizontal line that I plan on making invisible once I get it working. This actor is on the non-scrollable layer, the same one as the joystick. This way, it is always at the bottom of the screen no matter how far the main actor has flown upwards (the scene is about 4000px high). The camera control for the main actor is set to disable when the joystick is not in use, so that it will fall to the bottom of screen without the camera following.
I am trying to destroy the main actor (and change scene) once it touches the horizontal line at the bottom of the screen. This works fine using a simple rule (actor collides with actor of type horizontal line -> destroy actor) BUT it only works when the horizontal line is at the true Y=0 of the scene. It does not work after the camera has followed the main actor even just 1 pixel upwards. The main actor simply passes through the horizontal line actor without being destroyed.
I have tried using the rule mentioned above, I have tried destroying the main actor when its Y position is equal to that of the horizontal line + 0.5 the height of the main actor and I have tried putting the horizontal line on a scrollable layer and moving it at the same speed that the main actor flies at (while constraining X to 0.5 screen width). The problem with my last attempt was that the horizontal line would move to about 40% of the way up the screen before the camera control started, and that's where it would stay for the rest of the level.
Sorry for the long description, I hope someone can help
Thanks.
Best Answer
-
BBEnk Posts: 1,764
physics on actors on non-moveable layers stay put when the camera is moved even though the image is still visible.
So what I do in my games is I create a actor called "tack" and constrain that to camera origin, and this way I have something to keep things were I want them. So this way you could constrain your ground to the tack and it will follow camera and you can set it non-movable on a movable layer.
Answers
Yeah I thought it was something like that because the self.position.X for the ground wasn't changing, thanks!
@karlpower
here I made a little demo to show a way to make it work.
1st scene shows how I might make it work.
2nd scene shows what happens when you move camera up 50 px and have the ground on a non-movable layer. you will see player bounce at the grounds original position not were it's image is sitting.
Cool thanks a lot, appreciate it!