elevator / moving platforms (up and down)

Hi everyone,

I am using Lime to create a map. I got an object moving up and down by doing this:

function elevatorMove()   
 if elevator then  
 function moveDown()  
 transition.to( elevator, { time=3000, x=(elevator.x), y=(elevator.y + 175), transition = easing.linear, onComplete = moveUp } )  
 end  
 function moveUp()  
 transition.to( elevator, { time=6000, x=(elevator.x), y=(elevator.y - 175), transition = easing.linear, onComplete = moveDown } )  
 end  
 moveUp()  
 end  
end  

The problem is I can’t make this object static so when the player hit the object he will move with the platform up and down.

How can I do this or I might ask what am i doing wrong?

b-bond [import]uid: 120513 topic_id: 21525 reply_id: 321525[/import]

Hey there - why can’t you make it static, sorry? [import]uid: 52491 topic_id: 21525 reply_id: 85480[/import]

I figured it out I have some of the properties saved in external json files and my mistake was trying to make it static calling that file.

instead what i have done is this

physics.addBody(elevator, "static", { density = object.density, friction = object.friction, bounce = object.bounce })  

now it works.

Thans for the patience and the reply peach pellen

B-bond
[import]uid: 120513 topic_id: 21525 reply_id: 85486[/import]

Maybe you or someone else can answer this question. why are moving objects standing still when hitting the static elevator?

is some kind of force applied to the element hitting the elevator by default?

b-bond [import]uid: 120513 topic_id: 21525 reply_id: 85516[/import]

My guess is they’re hitting part of the elevator’s body and can’t move further.

If it’s static and has a square body that others walk into they can’t “enter” the elevator.

If this is the case you’d want to make a custom body shape, perhaps like an “L” so the player could walk in and out.

Does this sound like your situation? (I’m trying to picture what you are going for so could be way off, please feel free to correct me.)

Peach :slight_smile: [import]uid: 52491 topic_id: 21525 reply_id: 85587[/import]

Not quite what I am aiming for. It is basically a part of the earth moving up and down (old school platform).

But when I try to detect collision it dosen’t work. Collision on all other elements work, so I am quite blank on why this is not working 0.o [import]uid: 120513 topic_id: 21525 reply_id: 85739[/import]

can it be because I am using transitions to move the elevator?

b-bond [import]uid: 120513 topic_id: 21525 reply_id: 85741[/import]

Ah I see; http://developer.anscamobile.com/reference/index/bodybodytype

The dynamic object would be listening for the collision in this scenario.

Take a read :slight_smile:

Peach [import]uid: 52491 topic_id: 21525 reply_id: 85768[/import]

I read the articles a couple of times,

with all other objects I check for collision with the player, the ground for instance (player should be dynamic). It seems to be the elevator only that dosen’t check for collision. The only difference is that the elevator has a transition.to on it. [import]uid: 120513 topic_id: 21525 reply_id: 85770[/import]

So the player is the one listening for the collision with the elevator but it doesn’t trigger, is that right? (Just trying to picture all this.) [import]uid: 52491 topic_id: 21525 reply_id: 86028[/import]

I think you pictured it right, the gravity still beep up when I place either a barrel or the player on the elevator :slight_smile: [import]uid: 120513 topic_id: 21525 reply_id: 86830[/import]

OK, are you still having the issue? Player collides with elevator but nothing happens?

I’d be tempted to use a transition on the elevator if it is static.

Is that an option?

Peach :slight_smile: [import]uid: 52491 topic_id: 21525 reply_id: 86859[/import]

I will just paste a bit more code here, as it might help :wink:
This is the elevator movement

function elevatorMove()   
 if elevator then  
 function moveDown()  
 transition.to( elevator, { time=3000, x=(elevator.x), y=(elevator.y + 175), transition = easing.linear, onComplete = moveUp } )  
 end  
 function moveUp()  
 transition.to( elevator, { time=6000, x=(elevator.x), y=(elevator.y - 175), transition = easing.linear, onComplete = moveDown } )  
 end  
 moveUp()  
 end  
end  

This is the collision (it dosent work)

function onPlayerCollision(event)  
 if event.phase == "began" then  
 if event.other.IsElevator then  
 jumper = true  
 print "le elevator"  
 end  
 end  
  
 if event.phase == "ended" then  
 if event.other.IsElevator then  
 print "This is not le elevator"  
 jumper = false  
 end  
 end  
end  

here is the elevator body

[code]
physics.addBody(elevator, “static”, { density = object.density, friction = object.friction, bounce = object.bounce })

and here is the player body

physics.addBody(player, "dynamic", { density = object.density, friction = object.friction, bounce = object.bounce })  

Hope this helps :slight_smile:

Thank you in advance Peach or anybody else :slight_smile:

b-bond [import]uid: 120513 topic_id: 21525 reply_id: 86865[/import]

Oh and the IsElevator is set in my json file

{ "IsElevator":"", "friction":0, "isSensor":"", "sheet":"elevator.png", "sheetData":"elevator" } [import]uid: 120513 topic_id: 21525 reply_id: 86866[/import]

Have you set any other bodies up this way? What happens in began phase if you do print (event.other.isElevator) ? [import]uid: 52491 topic_id: 21525 reply_id: 87063[/import]