In my game i am using LinearImpuls for jump player body and ApplyForce for movement left-right .But the problem is that when player jump at that time if movement occur then player speed so increases its just look like running on air.
So what to do to resolve this problem??
Thanks in advance
I think keeping a check by boolean variable in code that at one time only one action can be performed either jump or moving left and right will solve the problem until and unless it does not affect your required movement.
Related
I have an issue where when I use the physics system to have collision between the character and the wall, the Sprite will SOMETIMES vibrate when you hold to move into the wall. As an additional thing as they may be related, if I turn up the player's speed value they're able to glitch through the walls. Right now the collision system I have is really basic, so there isn't much coding but here's related info.
Wall's density is set to 0 while player is .1
Room has physics enabled but has no set gravity
I have a drag and drop collision event with only a comment in it.
https://docs.yoyogames.com/source/dadiospice/001_advanced%20use/more%20about%20objects/physics.html
Restitution: In physics, restitution is defined as "the return of an object or system to its original state after elastic deformation", but as the fixtures in the GameMaker: Studio are really rigid bodies and cannot be deformed, restitution is really a way of saying how "bouncy" the fixture is. This setting will affect how much an object "bounces" when it collides with other objects and is co-dependant on other forces that act on the instance like gravity and friction.
That could be ansver to "vibrations". Else you may tru to create code which will check if object is trying to move towards obstacle and stop its movement to prevent built-in physics from causing any problems.
wall skipping: This is usual behavior of built-in game-maker collisions. main problem is that game-maker "teleports" objects "by speed in its direction", which means that when speed is greater than size of any object, game-maker collision system may fail.
I have just added a linear impulse function to move my object from left to right when the user moves their finger back and forward across the screen. The object is also falling by the worlds gravity.
After the object reaches a boundary i want to stop the linear impulse. I understand that i should add linear dampening however that then stops the gravity for applying its force.
Is there anyway i can stop the side to side impulse without effecting the gravity.
Thanks
Yes, simply set body.linearVelocity.x = 0;
One of the powerups in my game is a vortex that attracts all coins. I know I have any cocos2d's moveto/bezierto methods available, but I don't know how to make them have tangential and radial speed.
The extra difficulty is that the vortex center can change in every step, so all movement has to be readjusted.
One way to achieve this without a physics engine is to use the rotation around point algorithm.
That covers the rotation around the vortex center. Once an object is rotation around the vortex, all you need to do is to reduce that object's distance from the center by a certain amount every frame. That way it will continue to move inwards.
The only tricky part then is to get the object from its initial position being "sucked into" the vortex. There's going to be a lot of tweaking needed. With a physics engine, that part would come natural from the physics itself and it would always look right.
This is not guaranteed for the manual solution and definitely not for actions, which aren't designed to track moving targets. For example, if you change a move action every frame by replacing the existing one with a new one, your object won't move at all. Every time you do that, there's a 1-frame delay before the new action does its work.
I am developing third-person shooting game using Bullet and Ogre. When the character model collides with an object in the world, such as a power-up, the collision applies a force to the character and causes them to spin. How can I prevent the collision applying a force to the character?
I have set a method for btDynamicsWorld::setInternalTickCallback and so I know which bodies are colliding and the btManifoldPoint.
Note that I applyTorque to the body in order to rotate them smoothly so I cannot simply prevent rotation.
Thanks for your help.
I am unfamiliar with the physics engines you mentioned, but I know a thing or two about real physics...
Basically if you draw a free body diagram and arrows that represent the forces, you can determine the net effect. Or if you know the desired net effect, you can figure out where you need to add forces or remove forces.
You could add an equal and opposite force/torque at the time of impact. This would make the net forces on your object zero.
Or you could take the elements that are causing the forces and make them massless. Force = mass * acceleration. If the mass is zero and your physics engine is based on real world physics, then it shouldn't cause any net forces on collision.
Hope that helps.
I have been experimenting with the box2D sample project within cocos2D for the iPhone and am wondering if box2D is the appropriate engine to use to make a moving object "stick" to a stationary object when the moving object is finished moving in a certain direction.
Here is a simplification of what I am trying to achieve: I have MovingObject, a dynamic rigid body, that moves vertically against gravity when enough force is applied to it. As MovingObject moves, it may overlap a static object, StationaryObject. When gravity diminishes MovingObject's velocity to zero such that it is no longer moving, I would like to have MovingObject remain where it is ONLY if it overlaps StationaryObject. If the object's do not overlap, MovingObject should start to move back down towards the ground per the force of gravity. During that descent, if MovingObject at any time overlaps StationaryObject, it should stop its descent and remain in that location as if it is stuck on StationaryObject.
I am able to get MovingObject to move per the forces I am applying to it, but not really sure how to make it stop and stay there once it reaches the top of its ascent, assuming it is overlapping StationaryObject.
Currently, I am experimenting with simple square/box objects but eventually both MovingObject StationaryObject will be defined as very different complex polygon shapes.
Thanks in advance for any insights and/or suggestions for achieving this.
Sounds like you'll want to change the type of fixture used for "MovingObject" while it "ascending" and then change it when it is "descending" so that it reacts differently (to overlaps).
by "overlap" it sounds like you want to achieve something similar to "one sided platforms" in a platform game (ie; Mario Bros.) - I would recommend looking into the solutions for one-sided platforms for starters.