#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Contrain Y Position between 2 points

Posts: 86Member, PRO

This should be easy but it is driving me crazy... I have an actor which is already contrained to an x position, and can be moved up an down based on touch position... However, I only want to be able to slide up and down between two y points (such as between y= 200 and y=500.... How do I do this? Thanks.

• Posts: 280Member, PRO

Hi! you can do in one line:
Constrain self.positionY To min(max(game.mouse.position.x,200),500)

• Posts: 11,313Member, Sous Chef, PRO, Senior Sous-Chef

@CasualEvolution said:
Hi! you can do in one line:
Constrain self.positionY To min(max(game.mouse.position.x,200),500)

I think you meant game.mouse.position.y...

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 280Member, PRO

Ups! > @tatiang said:

@CasualEvolution said:
Hi! you can do in one line:
Constrain self.positionY To min(max(game.mouse.position.x,200),500)

I think you meant game.mouse.position.y...

Ups! You are right