Tag Info

New answers tagged

0

You could use the Marching Squares algorithm to generate the 2d-mesh you want. After using the marching squares to outline the object, you could use this library to do the triangulation.


0

The path of fewest changes involves keeping your rotation sign as another variable in the function scope. You can acquire it by taking the cross product of the force and your moment arm. After your momentArm assignment, add the following: Vector3 rotation = Vector3.Cross( new Vector3(momentArm, 0), // the Vector3(Vector2 v, float z) constructor ...


4

What you're looking for is some dampening function, i.e. friction with the table. Dampening is actually a rather easy function: v *= factor; Where factor is a number between 1 (no dampening) and 0 (immediate halt). The actual number for factor depends on your surfaces. For example, 0.99 could be ice, 0.9 could be some grass, 0.8 could be sand. You'll ...


0

After looking through the documentation for PhysicsJS I couldn't really find anything but I would access your velocity vector and over time reduce that velocity to simulate friction. //Java (yes i know its not Javascript) public void update(){ if(vx > 0){ vx -= 0.01f; } if(){ vy -= 0.01f; } } Thats how I would do ...


0

I solved this problem once by creating a 'rail' (which was just a line located above all blocks.) A rail would exists above all blocks and govern the horizontal and vertical movement of the character. Two rails that touched would connect to each other, allowing the character to move seamlessly from one block to another. If the character touched a block and ...


0

This is a non-trivial problem. See http://www.reddit.com/r/gamedev/comments/1w92dm/2d_collision_detection_and_resolution_solving_the/, https://www.iforce2d.net/b2dtut/ghost-vertices . If all your blocks are axis-aligned, the easiest solution would be to prioritize collisions with normals along the y-axis. One common solution is to use "rounded" corners for ...


1

You can create a manager script that keeps count of how many rigidbodies are currently not sleeping as so (VERY simple example): using System; using UnityEngine; using System.Collections; public class SleepTracker : MonoBehaviour { public static SleepTracker Instance { get; private set; } public event Action onAllObjectsSleeping; private int ...


0

Here's a brute force way to do it... bool allSleeping = true; Rigidbody2D[] allBodies = FindObjectsOfType<Rigidbody2D>(); foreach(Rigidbody2D body in allBodies) { if(body.isAwake) { allSleeping = false; break; } } return allSleeping; Note that FindObjectsOfType is slow - you don't want to do this every frame. If possible, ...


2

The simplest way to find out how a physics-based sequence would turn out is to simulate it. Sample the positions as you go and draw indicators on suitably spaced places. This works regardless of the model you're using, may it be an actual simulation or some simplified model like "follow this parabolic path".


3

Simple Solution If you want the body to instantly rotate just call Body::setTransform and pass the current position and the desired angle, don't bother applying torques or anything. The function call could be something like this: body.setTransform(body.getPosition(),myDesiredAngle); Physics Solution If you want the player body to interact with bodies ...


2

If you are looking to mimic old school platformers step one is to ditch physics altogether. You will end up fighting the physics system to get the decidedly non-realistic motion of an old school platformer. Have a look at this CharacterController replacement that ditches physics altogether to get a good idea of one way to implement it.



Top 50 recent answers are included