More problems with my upcoming game.. Head is flying away.. (video included)

OskarDeveloperOskarDeveloper Member Posts: 533
edited September 2012 in Working with GS (Mac)
So I am working on a racing game or something and at first i tried having the car in one actor but i looked really bad when landing upside down, because of the collision shape. So i figured that i could make them to two actors, one the head and the other a "body" actor.. I constrained the heads X and Y to the bodys X and Y but with like +10 pixels or something and it looked pretty neat, i also constrained the rotation so that they have the same rotation.. But still i am doing something wrong.. Please help me solve this..

Best Answers

Answers

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Post a picture of your rules in the head.
  • OskarDeveloperOskarDeveloper Member Posts: 533
    edited September 2012
  • LumpAppsLumpApps Member Posts: 2,881
    edited September 2012
    Hi there, you have used a constrain to the cars position X and Y. So what is happening now is correct. What you want to do is use a sin and cos to have the head rotate with the car.
    The constrains should be:
    For X: car position + (radius*cos(rotationCar))
    For Y: car position + (radius*sin(rotationCar))
    Where radius is the radius from the cars center ( positionX and Y) to the positions of the heads center (positionX and Y)

    It could be that I have the sin and cos the wrong way round. Because I am not at my Mac now and doing it out of my head. ;)

    Another thing is you do not need game attributes for the x and h of the car. When you open the head that is in the scene and unlock it ( click the big lock) you get acces the cars attributes.

    Let me know if it works. I can look it up later if it's wrong.
    Also do a search for mosinus on the forum. I made a tool that helps.
  • OskarDeveloperOskarDeveloper Member Posts: 533
    thanks alot @LudwigHeijden ! I think i know how to make it but when i try it my head just keeps exploding… Is there any way you would have the time to make a template or something for me?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited September 2012
    Also uncheck moveable and don't us collision on the head. Just let the head be linked to the car. When you constrain a position you don't need it to be moveable. I have feeling it's going wrong during collisions.
  • OskarDeveloperOskarDeveloper Member Posts: 533
    I cant get it to work...
  • LumpAppsLumpApps Member Posts: 2,881
    Why not?
    carpositionX+(radius*cos(CarAngle+90))
    carpositionY +(radius*sin(CarAngle+90))
    Should be right, I just checked. the +90 is beacues the head should be on top of the car, not on the front ;)
    Did you have the cars position (x and Y) and its angle (rotation) constrained to game.attributes? Also constrain the heads self.rotation to the cars rotation.
    Experiment a bit with this, you'll get it I am sure.
  • OskarDeveloperOskarDeveloper Member Posts: 533
    edited September 2012
    hum...
  • LumpAppsLumpApps Member Posts: 2,881
    Radius should be the distance from the center in the car to the center on the head. So if your head imhas an x offset of 32 and a y offset of 16 you put this in the appropriate constrain.
    Didymium are pretty smart because I see you put the constrain in the car and not in the head. I never thought of that.
    If you want me to look at your project mail me at info at lumpapps.com but you will have to wait for tommorow because I am done working for today ;)
Sign In or Register to comment.