Problem to control platform with platformlock

I'm in the last task befor the array chapter, with creating my own world.

No I'm facing the problem the the platforms do not react on the platformlock.


my code is locking that way:

world.place(PlatformLock(color: green), facing: west, atColum: 7, row: 6)

world.place(Platform(onLevel: 2, controlledBy: PlatformLock(color: green)), atColum3, row: 0)


In my code the platform is not moving up when the PlatformLock is getting triggered by the expert.

In the previous chapter with existing platforms, I do see they have the color of the PlatformLock. My ones are all the same color and I think that could be the problem, doesn't it?


How can I match each Platform with its PlatformLock?


Thanks your any idea :-)

  • This worked for me:

    let platformLock1 = PlatformLock(color:  colorLiteral(red: 1.0, green: 0.1491314173, blue: 0.0, alpha: 1.0))

    world.place(Platform(onLevel: 2, controlledBy: platformLock1), atColumn: 0, row: 2)

    world.place(platformLock1, atColumn: 6, row: 3)

Add a Comment

Replies

Hi, I met the same problem with you. May I know have you find out the solutions for this?

Also having this issue in Learn to Code Playground 2.

expert.turnLockUp() and expert.turnLockDown() don't affect the platform elevation.

so what you need to do is that you need to create an instance of a PlatformLock()

let pfl = PlatformLock()

once you have create and instance you need to connect it with the platform, you can either connect it directly or can make a instance as well and put your instance pfl in controlled arrtibute

let pf = Platform(onLevel: 1, controlled: pf1)

and now you can place both of them in a world so once they are operated they will be communicating.