More problems with my upcoming game.. Head is flying away.. (video included)
OskarDeveloper
Member Posts: 533
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..
Answers
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
Lump Apps and My Assets
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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.
Lump Apps and My Assets
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
Lump Apps and My Assets