Floating actors

robzrobz Member Posts: 50
edited November -1 in Working with GS (Mac)
Please help, I have a demo game with buttons for up, down, left and right. These buttons are used to move squares in my game (when selected). The squares stop when colliding with surrounding walls and other squares. However If I select a square and move it into another square that is on a wall they collide and all is ok fo a second but then they start to float.
I have tried changing the objects moveable but its not working.
So my question is how do you lock / unlock an actor (position wise) at will or on collision

Thanks

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    you can try setting the actor's linear.X and linear.Y to 0
  • robzrobz Member Posts: 50
    Thank you, this solved part of my problem. just need to work on locking but i think i now have material to work with
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    You could try raising the density setting in actors you don't want moving after a collision.
  • robzrobz Member Posts: 50
    thank you for answers, both work on simple demos. I think my problem is with the timer i am using to move the squares from one side of the screen to the other or up and down - on one button click. Am i correct in thinking moveable (true / false) is a design time setting or does not work with the spawn actor.

    PS thank you, i now have more options to play with; so back to the fun.
  • robzrobz Member Posts: 50
    concluded that there is no way of making an actor none moveable other then at design time.
    Setting linear x/y to 0 and changing density work in part but if you continue colliding with these actors they start to move (very slow) but still move. I have even attempted to track the actors X any Y in integers and constrain self.position.X and self.posiyion.Y to these values, and nothing changes.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    may cause a memory slowdown but maybe when there is a collision a new actor is spawned in the correct position and in the new actor you uncheck the movable choice in the attributes.

    just an idea
  • robzrobz Member Posts: 50
    Thanks

    I have considered that, however i will have upto 15 actors that will need this. I also want to be able to "click to reactivate" these actors at any point so they can be moved again. Thats a lot of spawning.
  • robzrobz Member Posts: 50
    FIXED FLOATING ACTORS

    after much experimentation i have fixed my floating actor problem. If anyone else has this problem this is how i did it

    give your actor 2 real attributes, i named them LockedX and LockedY. When you want to stop your actor from moving (completely) set the new attributes to the actors Position X and Y then immediately constrain the actors Position X and Y ( or (X or Y)) to the values in the attributes

    e.g
    self.LockedX = self.PositionX
    self.LockedY = self.PositionY

    constrain attribute self.PositionX = self.LockedX
    self.PositionY = self.LockedY

    hope this helps anyone with this problem
Sign In or Register to comment.