Problem with walls collision

gregoirephilippegregoirephilippe Member Posts: 5
edited October 2012 in Working with GS (Mac)
Hi there,

first of all I just want to say that I've searched an answer to my problem a lot on this forum and the internet and the solutions I've found don't work, so here I am :P

Here's my problem. I'm doing a top-down maze level. So I have my avatar actor and my wall actor. I've put my wall several times on the screen to make a maze. I've found a lot of threads telling me how to make the walls «solid», but nothing works. I've turn the wall to non-movable, put its bounciness to 0, added a collision behavior on it, but when I preview my game, my avatar just move OVER every wall. If I put my wall actor to movable, then now the collision works but like you can guess, my walls just move all over the place.

Can someone help me ?

Comments

  • gamesfuagamesfua Member Posts: 723
    How is your avatar moving? I'm going to guess and say by dragging (i.e. touching/clicking the actor and dragging with finger/mouse). If this is correct- it's not because I'm psychic, it's because a mouse driven actor doesn't abide by collide rules.
    One video in particular that might help you out, is this one...


  • UtopianGamesUtopianGames Member Posts: 5,692
    Have you got movable checked in the avatar because in order to use collide at least 1 of the actors has to be movable.

    Darren.
  • gregoirephilippegregoirephilippe Member Posts: 5
    The video demo would be perfect, but my avatar is constrained to the mouse movement, so I'm not sure how to change the behaviors to make it possible for my project. It's a school project so my avatar has to be constrained to the mouse movement at all time (wherever my mouse goes, my avatar goes). Yes my avatar is movable.
  • gamesfuagamesfua Member Posts: 723
    Ah, see, i was correct! That video should still apply to your needs. I had this same problem. Mouse avatars don't collide well. There needs to be lag (shown in the video) of the avatar to the cursor- thus allowing for proper collisions. So check the video again. Otherwise you can possible constrain your actor to certain areas of the screen. Meaning set a defined constraint for the avatars x and y position so it can't go beyond certain points. Let me know if you need any more details.
  • gamesfuagamesfua Member Posts: 723
    Just realized that the video is merely a demo instead of tutorial. Sorry about that. But it is the tutorial you need! Look for tshirtbooth tutorials on constrain mouse with collision.
  • gregoirephilippegregoirephilippe Member Posts: 5
    It's not exactly what I needed, but by trying a few things, I've found how to do it. Here's my solution to the problem if someone else needs the answer :

    I took his line of constrain attribute out of his original rule (now it doesn't have a rule attached to it) and added the trick to cancel the camera offset () at the end of the line so it gives this :

    self.Motion.Linear Velocity.X to 20*( game.Mouse.Position.X - self.Position.X + game.camX)
    self.Motion.Linear Velocity.Y to 20*( game.Mouse.Position.Y - self.Position.Y + game.camY)

    Now it works !

    Thanks for your help everyone !
  • gamesfuagamesfua Member Posts: 723
    Fantastic!
Sign In or Register to comment.