Hello,
I am having some issues with Kinematic objects. I am currently making a platformer game. My main player is a dynamic object (since I need it to rotate), my environment is static. One of the features of the game is a "door" that can be activated with a switch. When the switch is pressed, the door will start moving up, slowly, and after a few seconds, the door will close automatically.
Since my game is tile based, I decided to not make the door a single object, but rather pieces connected as a linked list. When the door opens, all pieces move together, each part stopping when it gets to the "door base", kinda like folding. When the door closes, the first piece will move, after it goes to the next tile, the next piece will move, and so on, until the first piece touches the ground, and all of them will stop moving at once.
Since I need to set force or velocity, a static object is out of the question. I tried using dynamic objects with a very high density, but the player was still able to move it, so my last choice was a kinematic object. It works great with the player, since its dynamic, and it does not collide with the base, since thats static. The main problem is that I would like the collision with the next tile:
For example, a door that opens sideways
1BDDD2
where 1/2 are wall, B is the base, and D is the door part. Initially the door will open towards 1, and the second that each D collides with 1, their velocities will be set to zero. When the door closes, the first D will move, then the second and so on until the first D collides with 2, and all of the door parts will stop.
The main problem is that 1 and 2 are static objects, and as such don't collide with kinematic objects. I could set up some sort of dynamic sensor in 1 and 2, and the second the ContactListener lets me know that the door part collided with it, then I will do the correct behavior.
My question is, is that the only way for me to achieve this behavior? or is there a better way (rather than me having to place sensors all over the place where the doors are).
Here is the link to the current build of my game (its going to be a facebook game). https://apps.facebook.com/_repulsetest/ The orange thing is the door base. This build does not have the door parts yet, but at least will give an idea how it will look.
Thanks in advance!
I am having some issues with Kinematic objects. I am currently making a platformer game. My main player is a dynamic object (since I need it to rotate), my environment is static. One of the features of the game is a "door" that can be activated with a switch. When the switch is pressed, the door will start moving up, slowly, and after a few seconds, the door will close automatically.
Since my game is tile based, I decided to not make the door a single object, but rather pieces connected as a linked list. When the door opens, all pieces move together, each part stopping when it gets to the "door base", kinda like folding. When the door closes, the first piece will move, after it goes to the next tile, the next piece will move, and so on, until the first piece touches the ground, and all of them will stop moving at once.
Since I need to set force or velocity, a static object is out of the question. I tried using dynamic objects with a very high density, but the player was still able to move it, so my last choice was a kinematic object. It works great with the player, since its dynamic, and it does not collide with the base, since thats static. The main problem is that I would like the collision with the next tile:
For example, a door that opens sideways
1BDDD2
where 1/2 are wall, B is the base, and D is the door part. Initially the door will open towards 1, and the second that each D collides with 1, their velocities will be set to zero. When the door closes, the first D will move, then the second and so on until the first D collides with 2, and all of the door parts will stop.
The main problem is that 1 and 2 are static objects, and as such don't collide with kinematic objects. I could set up some sort of dynamic sensor in 1 and 2, and the second the ContactListener lets me know that the door part collided with it, then I will do the correct behavior.
My question is, is that the only way for me to achieve this behavior? or is there a better way (rather than me having to place sensors all over the place where the doors are).
Here is the link to the current build of my game (its going to be a facebook game). https://apps.facebook.com/_repulsetest/ The orange thing is the door base. This build does not have the door parts yet, but at least will give an idea how it will look.
Thanks in advance!