help with attributes

Uppy83Uppy83 Member Posts: 5
edited October 2014 in Miscellaneous

Hi guys, I'm making a very very simple proof-of-concept demo of a game idea, what I'm basically trying to do is get a tray at the bottom of the screen to move left or right when a left or right button is pressed on screen.

I've figured out how to get the tray to go right, but how do i make it stop when it reaches the edge of the screen?

Comments

  • LovejoyLovejoy Member Posts: 2,078

    Create an invisible wall actor and have the tray collide with it. Make sure you change the actors physics to your liking.

    Fortuna Infortuna Forti Una

  • metametmetamet Member, PRO Posts: 80

    You can do one or two things. 1) Put a constrain attribtue self.position x to be greater than or less than the sides. Or put walls there. In the walls, make sure to change their physics and unselect "movable" and check "fixed rotation" or they will be collided into. In your actor you should specify that it bounces when colliding against these walls.

  • colandercolander Member Posts: 1,610

    I put some values in below but obviously change them to whatever you want. Also consider using self attributes for these values. When you have a lot of rules in an actor it can be hard to locate them and they are usually needed in other parts of the code. If they are needed in other actors they will have to be game level attributes. This way if you need to change them you can do it in one place (In the attributes panel) instead of looking through all the code and making the same change multiple times.

    Constrain Attribute - self.Position.Y To 50
    Constrain Attribute - self.Position.X To min(max(self.Position.X, 100),500)

  • Uppy83Uppy83 Member Posts: 5

    Thank you, I've done that, another stupid question, how do i get they tray to stop when someone isnt touching the button on the screen? I selected change velocity, but it still moves to the edge of the screen.

Sign In or Register to comment.