Tag Info

New answers tagged

0

You can lock an object to move along one axis by constraining its motion. See the documentation for Rigidbody.Constraints and RigidbodyConstraints. From the first link: Rigidbody.constraints Controls which degrees of freedom are allowed for the simulation of this Rigidbody. By default this is set to RigidbodyConstraints.None, allowing rotation and ...


1

For a one-off change of velocity, I'd recommend changing velocity yourself. So rather than applying a force to the object, try something like rigidbody2D.velocity += shooter.velocity after you create the shot and figure out the regular shooting velocity. Secondly, it'd probably be best not to count on the speed difference to avoid the shooter being ...


0

I would have done this by using rigidbody and applying force to ball only for y-axis. you can use transform.up to get the up vector to apply the force. To detect whether the ball has touched the ground or not, I would raycast to bottom of the ball so when raycast hits I could understand that the ball is on the ground or on top of something so you could apply ...


0

If you only want to change the physicsBody to static, you can do this using cocos2d-x scheduleOnce with delay = 0.0f. You might have to manually schedule the physics step but it should work in any case. For instance, let's say you want to make shapeA static when a collision is detected: bool HelloWorldScene::onContactBegin(PhysicsContact& contact) { ...


1

One simple way to simulate soft bodies is to connect together small rigid bodies with elastic joints. Then the difficult part is to fine tune your model's parameters and map the texture to the underlying model. The following blog post provides an implementation of a deformable ball with cocos2d engine: ...


0

It is now quite some time after the original question was asked; Chipmunk shapes have a property called "elasticity" which is a number from 0 to 1. Setting it to 1 for both bodies you want to collide will ensure perfectly elastic collisions. However, you mentioned that you want to "keep moving bodies moving at a constant speed". This is physically incorrect ...


0

Your velocity is 0 when the ball stops, so the velocity must be 0 at the point where it would "overshoot" (when there's a direction change required in the paddle). You can set your velocity to 0 and change paddle direction when your paddle has reached the y coordinate of the ball.


0

I was able to achieve a precise gravity simulation by applying the 'correction' said in this article: http://www.niksula.hut.fi/~hkankaan/Homepages/gravity.html Basicaly it consists in dividing the gravity by 2 in the very first frame/iteration when adding it to velocity.


3

It's because of the discreet time and the way you integrate. Because you step time forward at 1/50 of a second you're not guaranteed to hit the actual apex of 4.0, the delta is just not granular enough. (Try setting the delta time to 1/5000 and you'll see that it gets closer to 4, obviously that won't work for your game but it will show you the effect). ...


1

It does not stop, if you don't have friction and gravity, that in normal world slow you down. When applying force, you are really not adding force at all and in fact i am bit surprised that it actually moves at all. You should apply more force, to get your object moving. Try something like this. Vector2.right = Thats the direction of the force Multiply by ...


1

Consider reading books about realworld physics. "In physics, a force is any interaction which tends to change the motion of an object." - Wikipedia. So... By applying force you make it accelerate and decelerate. You need to have friction or don't use physics at all to make it stop at the end of button press.



Top 50 recent answers are included