Moving Platforms, and their collision
TangoDownStudios
Member Posts: 46
I want to make a platform that moves across the screen. Simple enough right? Well here are the stipulations:
1. Platform must move from left to right changing directions when boundaries are reached
2. Platform must retain its initial Y location and only move in the X
3. Platform must interact with objects that fall on top of it (in this example, falling balls)
4. Platform must not rotate
So I create an object whos Y location is constrained to its initialY value. Good sofar. Oh wait... not good! The collision with the balls is now all jacked up! When the balls hit the platform it tends to want to warp right through it, or exhibit some very weird collision detection : ( So I try to constrain the YVelocity of the platform to 0 and it is a liiiitle better, but not by much.
So I'm screwed already! So suddenly into my design phase for an actor who should be very simple to create...
Any advice from the talented among us?
1. Platform must move from left to right changing directions when boundaries are reached
2. Platform must retain its initial Y location and only move in the X
3. Platform must interact with objects that fall on top of it (in this example, falling balls)
4. Platform must not rotate
So I create an object whos Y location is constrained to its initialY value. Good sofar. Oh wait... not good! The collision with the balls is now all jacked up! When the balls hit the platform it tends to want to warp right through it, or exhibit some very weird collision detection : ( So I try to constrain the YVelocity of the platform to 0 and it is a liiiitle better, but not by much.
So I'm screwed already! So suddenly into my design phase for an actor who should be very simple to create...
Any advice from the talented among us?
Comments
In the platform actor put whatever collide rules you want in it
then have a rule when self position x is less then or equal to 10( youll put the starting position ill use ten as a example)
interpolate self position x to 400 (another example replace 400 with wheever you want it to stop)
then have another rule when self position x is equal to or greater then 400(or whateevr you made the stop position)
interpolate self position x to 10(or whatver you made the starting position)
Create a Real game.attribute called PlatformY.
Then have a Constrain Attribute game.platformY to self.platformY, then a second Constrain Attribute self.platformY to game.platformY
I'd use an interpolate with timers for #1
Put a collision on the balls with the platform
Turn rotation off for #4 (Also, turn Moveable off). Interpolate will stil move the platform.
See where that gets you and let us know.
Make a real self.attribute call it startX
change attribute self.startX to self.position.X (this stores the X position of the platform in the scene so you can now place it anywhere).
make a rule if self.position.x = self.startX
Interpolate self.position.X to self.startX+100
otherwise (still using one rule)
if self.position.x = self.startX+100
Interpolate self.position.X to self.startX
You can now place this actor anywhere and have multiple copies and also change the travel distance for each platform.
Darren.