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.
Related
I am trying to make a very simple runner game, where a ball moves forward infinitely and your goal is to not let it bump into obstacles. I made a simple level with UE4 geometry, the ground is made out of different geometry objects. These objects are placed really close together, so there are, presumably, no gaps.
The engine is simulating physics for the ball.
I move this ball by executing this code every Tick:
FVector MoveForce(0, 1000000, 0);
BallMesh->AddTorqueInRadians(MoveForce);
I tried AddForce and AddImpulse before, they gave me the same result.
Here are the blueprint's components and Physics+Collision Details
Blueprint Screenshot
The main problem is, in places where the geometry connects (also on non-flat geometry), the ball just jumps, like there is a trampoline. And I can't figure out why this is happening.
Here is an example of the ball moving forward (to the left relatively to us) and then just jumping up.
enter image description here
I tried using new physical materials, disabling PCMs, changing the level's geometry. Nothing changed regarding the problem.
try if increasing mass would help,
I think this is happening because in collision detection it is not always very smooth but discrete in nature
also see if there collision primitive doesn't miss-aligned to each other.
The force you gave to the ball is quite large. In reality for that force, the ball should jump high in places of contact...because there is an addition to the upward normal force.
Solution:
virtual void AddTorqueInRadians
(
FVector Torque,
FName BoneName,
bool bAccelChange
)
When calling the function AddTorqueInRadians, set the boolean value of bAccelChange to true and see. This will allow you to use less force, as here torque is taken as change in angular acceleration instead of physical torque (mass will have no effect). This should work. And Bone Name is none.
Something like this:
FVector MoveForce(0, 20, 0);
BallMesh->AddTorqueInRadians(MoveForce, None, true);
Also, Uncheck MassInKg in blueprints for mesh.
I'm working on a Minecraft like game for educational purposes. The rendering is great so far even with 1024x1204 blocks but now that I started integrating the player collision I'm having problems.
I have a aabb for the player and aabb's for all the blocks around him. These are created dynamically and it works out pretty fast.
My problem goes as following:
I have speed vector and the current position. For each axis I calculate the potential position and make out an aabb. I check for collisions and it's free I move there otherwise I set the speed for that component to 0. I separate the axis since I want my player to slide in a direction of partially facing a wall.
The order for the axis is y,x,z. The collision response is great but I'm having some problems with the corners as it sometimes get's stuck in the world without being able to move. Not sure what the reason is for this.
I do not want to implement actual physics since those are more demanding and basically just too much for what I need.
Do you guys have any suggestions on how to implement this in a nice way? I did some searching but I didn't find anything useful for this particular situation.
This is a bit abstract in a sense that the cause of your problem can be related to many things. From the top of my head, maybe a bug in your collision detection code: somehow it allows the objects to cross boundaries by 1 (or more) unit. So when the next collision is computed 1 or more dimension is stuck (imagine having an arm already inside the wall when collision is detected. You can't get your arm out because it collide with the interior of the wall boundary)
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'm just starting with cocos2d + box2d.
I would love to create a simple 2d ship game where you look from top(from the sky) down at the sea with the ships.
Could someone give me a very very basic example, how to apply wind to my world? Do I have to applyForce to each ship body?
And what about the gravity? Since it goes straight down, should I set it to 0? gravity.Set(0.0f, 0.0f)? It actually would pull down the ship..
Should I somehow deal with the water? e.g with density of it?
you would probably have to detect where the ships are and then apply force on them somehow.
and yes set gravity to 0.
and water wouldn't have to be an object at all. just like a background image.
If you are looking from the top and want to apply wind force to all your ships you can use gravity vector. In this case wind force will be applied to your objects automatically.
If there are other dynamic objects on the scene then it's a good idea to keep the list (std::list or NSMutableArray) of pointers to all your ships. Notice, that by default box2D is clearing all the forces each simulation step. You can disable this property or apply forces manually each simulation step
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.