Tag Info

Hot answers tagged

5

It depends on the effect you are looking for. If you are looking for a constant gravity the answer is: object.AddForce(((Vector) sphere.center - (Vector) object.pos).normalized * gravityForce); If you are looking for a gravity based on the distance between the object and the sphere then you replace gravityForce with this formula: gravityForce = ...


2

You simply need a reworked Newton's law of universal gravitation. So F=G(M1*M2)/R2 translates as code into. // Create force scalar based off of distance. distanceSquared = (gravityCenter.y - object.y)^2 + (gravityCenter.x - object.x)^2 force = gravitationalConstant*distanceSquared // Get direction from object to gravity epicenter. direction = ...


2

This is fun! The trajectory is just a bunch of mathfz and a line renderer. Check out this post for more information on that which details how to calculate the trajectory. Line renderers are definitely your best bet for visualization. Even on mobile, 5-10 line renderers would be no problem. The alternative would be to hard-code the visualization with a ...


1

First calculate the line equation (the laser direction) <x,y,z> = <x0,y0,z0> + t*V (1) where V is the direction Vector, and is the a known position of your bullet. Second calculate the equations of each side of your entity, the intersection would be the point that satisfies (1) and one of the rectangle sides equations


1

Here's one very simple way to do it: package; import flixel.FlxG; import flixel.FlxSprite; class Player extends FlxSprite { public static inline var VELOCITY:Float = 4; public function new() { super(); // enforce subpixel-rendering for smoother movement pixelPerfectRender = false; } override public function ...


1

Your density calculation is correct. Either the weight of the human is too much, or you have got to make the human bigger. In real life your human would have more volume or less mass. Which one to select is entirely up to you. And since this is top-down, you can expect to get the wrong density of the human with that formula. If it was a side view game, it ...


1

This is an effect of the joint-solver that tries to keep the joints together but fails to do so when big forces are applied. This occurs frequently when a "rope" consist of a large amount of small individual elements and joints. Things you could do to improve the behavior: reduce the amount of joints in your rope. Example: Create a physics-chain with ...



Only top voted, non community-wiki answers of a minimum length are eligible