Collide rules not always working

Hi

Can someone help me out? I'm jumping through a platform and landing on top, sometimes it will collide correctly but other times my player will fall through it!

Advice would be greatly appreciated

Thanks

Dan

Comments

  • FirstDanFirstDan Member Posts: 208
    @fryingbaconstudios- thanks for your reply

    Rule
    When
    self.Position.X -( self.Size.Width /2)-( game.playerswidth /2)
    self.Position.X +( self.Size.Width /2)+( game.playerswidth /2)
    self.Position.Y +( self.Size.Height /2)+( game.PlayersHight /2)

    Collide

    End

    When player collides with platform actor
    Constrain self.motion.linear. X= 0 and the same for y...
    Else
    Change velocity

    Cheers

    Dan
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    You should be tracking the main players x & y through real gamelevel attributes and that code I see no operators. Have you seen this video?

  • FirstDanFirstDan Member Posts: 208
    edited December 2012
    @FryingBaconStudios - yes i have watched the video many times

    game.playersX > self.Position.X -( self.Size.Width /2)-( game.playerswidth /2)
    game.playersX < self.Position.X +( self.Size.Width /2)+( game.playerswidth /2)
    game.playersY>=self.Position.Y +( self.Size.Height /2)+( game.PlayersHeight /2)

    collide with player

    Very confusing

    Anyone out their to help?

    Dan


  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    You have that rule at the top of the list in the platform. Have you tried an adhoc to test it? The viewer is not reliable, it could be working perfectly fine but the viewer
    fps are not very good. I will do a test model and see.
  • FirstDanFirstDan Member Posts: 208
    @ Frying bacon studios - I'm testing it on adhoc, I did read that collide happens so fast that it skips!!
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    I just tested it out and it works fine. I would make sure your constrains are at the top of the code in the actor and the rule in the platform for collide at the top too. What are the FPS of your game?
  • FirstDanFirstDan Member Posts: 208
    50-60, my platform moves up and down. Can that be why?
  • LooseMooseLooseMoose Member Posts: 224
    I had this problem a while ago. My hero would not land on the platform if there was another platform that was higher than the platform I was trying to land on.
  • FirstDanFirstDan Member Posts: 208
    @kyukon- that's exactly my pickle!! Did you find a fix?
  • LooseMooseLooseMoose Member Posts: 224
    Without seeing how your game is set up I'm not sure this would be the best solution, but you could try unlocking all of your platforms if you don't have too many and put a rule in them like this. (this method doesn't need constraints)

    Platform rule:
    If self.position y + (self.height/2) is less than hero.position y - (self.height/2 + 5)
    Collide with Hero

    The + 5 in the hero equation is just to give you some leeway incase the pixels slip lower than expected due to gravity.

    I hope this method works for you, I'm going out now but I will be back later if you still need some help.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Yes a moving platform would create possible problems.
  • Hey I am having a similar problem. I have set my player character to have a rule :
    bounce when colliding with tag "Collide w/player". It had been working fine, but suddenly while adding a main menu and pause menu, i played it, and my character was no longer bouncing off anything at all. The strange thing is that when I bring in a new instance of lets say the actor that functions as the ground, it collides fine with that. Its the same actor as the ground actor that was already on the scene but the older instances dont work at all. The only way it starts working again is if i drag in new instances or i manually unlock the instances already on the scene and add a new bounce rule for that individual actor.
  • statesman88statesman88 Member Posts: 2
    Thank you, tharbk01! I've been having the same problem, and dragging out new instances fixed it. For now, anyway. I also found that behaviors work better in Windows Creator when I tell them to look for actors rather than tags. I didn't have this problem in Mac Creator.
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    @kyukon > This example below - how do you do it with rules?

    When you write a rule you can use the expression editor in the first instance.

    So the best you can do is self.positionY (then is - greater / equal / less) -

    How do you make a rule that does what you say below?
    Without seeing how your game is set up I'm not sure this would be the best solution, but you could try unlocking all of your platforms if you don't have too many and put a rule in them like this. (this method doesn't need constraints)

    Platform rule:
    If self.position y + (self.height/2) is less than hero.position y - (self.height/2 + 5)
    Collide with Hero

    The + 5 in the hero equation is just to give you some leeway incase the pixels slip lower than expected due to gravity.

    I hope this method works for you, I'm going out now but I will be back later if you still need some help.
    Many thanks :)
  • LooseMooseLooseMoose Member Posts: 224
    edited May 2013
    @matarua that code was for windows creator but for mac you could try this:

    Screen Shot 2013 05 26 at 5 25 27 PM

    This code was to let my hero land on the platform when falling down onto it but not collide when the hero is jumping up through it.
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    I have tried to optimize this greatly and seem to have done it by using transparent platforms that are in fact only 1px high. So all the code is

    game.heroY > self.Position.Y >>>>>>> collide.

    I have had issues with the player falling through the platform at times. Gamesalad is having to constrain my attribute all the time and then do a mathematical equation on top of that. I decided to simplify it greatly.

    This is perfect for my game. But for some it might not be good having more actors. The platforms are also a pain to work with on stage so you do that manually through the scene inspector.

    I have not fallen through my platform since - lets hope I don't! Cheers :)
Sign In or Register to comment.