Hi, I have an old version of the engine( 5.3.2 ), because of my programming language no one else writes the header files
I have a few questions:
-How can I change the position of an object?
through body.p := cpv (x, y); fails
-How can I get the result of the collision of bodies?
Set body position
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Set body position
That is how you set the position of a body. What fails about it?
Are you setting the position of the body every frame?
Are you setting the position of the body every frame?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 3
- Joined: Thu Aug 08, 2013 7:24 am
- Contact:
Re: Set body position
I have staticbody he must change the value of x to the value of the x mouse cursor accordingly I update the value of each frameslembcke wrote:That is how you set the position of a body. What fails about it?
Are you setting the position of the body every frame?
The failure of the body does not move
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Set body position
Static means that it something move or change. So when you move the body, Chipmunk won't update any shapes attached to the static body unless you use one of the cpSpaceReindex*() functions to let it know that it needs to.
The better solution is to use a "rogue" body. Create a body, but don't add it to the space. Chipmunk will update it's shapes each frame like normal (they are separate objects), but it won't update the body's position or velocity automatically.
Also, if you set a body's position each frame, you should also set it's velocity to match. Otherwise you are going to end up with mushy, non-realistic collisions. If you want to do mouse control, you may also want to look at how the Chipmunk demo implements that using joints.
The better solution is to use a "rogue" body. Create a body, but don't add it to the space. Chipmunk will update it's shapes each frame like normal (they are separate objects), but it won't update the body's position or velocity automatically.
Also, if you set a body's position each frame, you should also set it's velocity to match. Otherwise you are going to end up with mushy, non-realistic collisions. If you want to do mouse control, you may also want to look at how the Chipmunk demo implements that using joints.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 3
- Joined: Thu Aug 08, 2013 7:24 am
- Contact:
Re: Set body position
I created an ordinary object, but did not add it in the space. That helped, but if it is not in space, and there is no collision, the other bodies simply fail through.
If you add a space on the body naturally begins to operate the physical model. I can disable the rotation, exposing each frame angular velocity and the angle of zero, but even in spite of the fact that I change every frame of the object's position, it is all the same gradually "falling" down until a new collision, then he returns to the place.
I googled for the old version was the place to be cpSpaceRehashStatic, using it basically works, as long as it suits me, the only, the number of iterations is not displayed on the quality of physics, ie, the body anyway fail the same, regardless I will set 100 or 500 or 10000.
And one more thing. My project is a bit of a breakout. I created a circle, and each frame exhibited his speed, that there was no loss of energy, because after the collision, even if I expose the gravity on the y-axis at 0, sooner or later, the rate begins to fall.
Speed exhibition like this:
The problem is that it passes through the other objects, it is possible to fix something?
I had one more question about the collision, he in the first message. The point is that I will need to know the face "ball and bricks", which would then remove from the world of this brick
If you add a space on the body naturally begins to operate the physical model. I can disable the rotation, exposing each frame angular velocity and the angle of zero, but even in spite of the fact that I change every frame of the object's position, it is all the same gradually "falling" down until a new collision, then he returns to the place.
I googled for the old version was the place to be cpSpaceRehashStatic, using it basically works, as long as it suits me, the only, the number of iterations is not displayed on the quality of physics, ie, the body anyway fail the same, regardless I will set 100 or 500 or 10000.
And one more thing. My project is a bit of a breakout. I created a circle, and each frame exhibited his speed, that there was no loss of energy, because after the collision, even if I expose the gravity on the y-axis at 0, sooner or later, the rate begins to fall.
Speed exhibition like this:
Code: Select all
ball.v := cpv( 100, -100);
I had one more question about the collision, he in the first message. The point is that I will need to know the face "ball and bricks", which would then remove from the world of this brick
Who is online
Users browsing this forum: No registered users and 19 guests