Hi.
I made a Elevator that can move up and move down. but there is a Problem that when the Player Placed on and move to right or left, also Elevator move to right and left with Player.
I add SetSpritePhysicsMass() for fix this Problem that fix it a little. but also there is this Problem. I need know there is any way that only move to one direction (e.g: Y direction) without change another direction (e.g: X Direction)?
this is my code without Player that can move up and down:
// set display properties
SetVirtualResolution( 1024, 768 )
global move = 0
slider = CreateSprite (0)
SetSpriteColor (slider,255,28,28,255)
SetSpriteSize(slider,32,512)
SetSpritePositionByOffset (slider, 512,400)
moving = CreateSprite (0)
SetSpriteSize(moving,128,64)
SetSpritePosition (moving,450,550)
SetSpritePhysicsOn(moving,2)
SetSpritePhysicsCanRotate(moving, 0)
do
// Move Elevator ===============================================================
if GetSpriteY(moving) > 200 and move = 0 then move = 1
if move = 1
SetSpritePhysicsVelocity(moving, GetSpritePhysicsVelocityX(moving),-60)
endif
if GetSpriteY (moving) <= 200 and (move = 1 or move = 3) then move = 2
if move = 2
SetSpritePhysicsVelocity(moving, GetSpritePhysicsVelocityX(moving),60)
endif
if GetSpriteY (moving) >= 550 and move = 2 then move = 3
if move = 3
SetSpritePhysicsVelocity(moving, GetSpritePhysicsVelocityX(moving),-60)
endif
// END ===============================================================
Print( ScreenFPS() )
Sync()
loop