Moving a box with your finger WITHIN the camera
juzcook
Member Posts: 259
Hi guys, my problem at the moment is moving a box with my finger in a sidescrolling platform game. I've got the basic rules down where the box moves using these rules:
------
When Touch is pressed:
Constrain Attribute: [Self.Motion.Linear.Velocity.X]
To: [(Game.Touches.Touch.1.X) - (Self.Position.X)
Constrain Attribute: [Self.Motion.Linear.Velocity.Y]
To: [(Game.Touches.Touch.1.Y) - (Self.Position.Y)
Else: [Change Velocity to zero]
------
So my problem is that the box moves perfectly when in the bottom left hand corner of the level, but nowhere else. For example if I place the box anyway beyond X=500, Y=500, the box seems to think that I'm touching the screen way back at the start of the level. Can anyone see where I might've gone wrong? I hope I made this clear enough!
------
When Touch is pressed:
Constrain Attribute: [Self.Motion.Linear.Velocity.X]
To: [(Game.Touches.Touch.1.X) - (Self.Position.X)
Constrain Attribute: [Self.Motion.Linear.Velocity.Y]
To: [(Game.Touches.Touch.1.Y) - (Self.Position.Y)
Else: [Change Velocity to zero]
------
So my problem is that the box moves perfectly when in the bottom left hand corner of the level, but nowhere else. For example if I place the box anyway beyond X=500, Y=500, the box seems to think that I'm touching the screen way back at the start of the level. Can anyone see where I might've gone wrong? I hope I made this clear enough!
Comments
you'll need to follow those directions exactly
That leads to another problem though. I want to create a moveable area for the box, so that it can't be dragged across an entire level, but instead only used in a small puzzle specific area. With the rules mentioned above, the box can move straight through an object that it's set to collide with. I've been trying a few different things over the last hour and I can't seem to find something that just makes it work.