please help me with a constraining problem.
hi, ok so i have a actor on x=160,y=485, i want to slide this actor up and down when is pressed, having constraining y to mouse position works good but then it moves more than what i want so i try this, when tout constrain self position y to max((567+ self.Size.Width /2)),min((395- self.Size.Width /2)), game.Mouse.Position.Y )) i try height instead of width but no good. or can i interpolate it too?
Answers
So it looks like you would have "(395-(self.size.width/2))" for lower limit and
"(567+(self.size.width/2))" for the upper limit.
That should work.
max(min( game.Mouse.Position.Y ,320),0)), now this works good, just would like to know why if i set my playing area from y=320 to y=640 won't work, so i will change the rule to
max(min( game.Mouse.Position.Y ,640),320)), i think this is a problem i don't understand about the offset position.
Here's what I would do. Create a real game attribute called game.CameraY
create an actor called camera. Make this actor immovable and invisible.
Drag this actor into your scene, unlock it and create the following rule:
constrain game.CameraY to current.scene.camera.origin.Y
Now go into the actor that you are trying to constrain and do this:
max(LowerLimit,min(UpperLimit, game.Mouse.Position.Y+game.CameraY ))