Tag Info

New answers tagged

0

The trajectory of the particles is a Bézier curve. A Bézier curve is a smooth curve along four points: pointA: startpoint pointB: startdirection+acceleration pointC: enddirection+accelleration pointD: endpoint Basically it generates a curve through from point A to point D, using the vectors towards A-B and C-D to determine the path. See C# (Monogame) ...


0

Objects shouldn't pass through each other if both have colliders. You could disable isKinematic on the rigidbody and then use AddForce to push. You could use also transform.translate() to move the player.


0

This worked for me float rotationSpeed = 1; transform.rotation = Quaternion.RotateTowards(transform.rotation,Quaternion.euler(0,0,-rotZ), rotationSpeed); rigidbody2d.AddForceAtPosition(transform.up * Thrust, transform.position - transform.up); Thanks everyone who helped!


2

Sorry everything would look nicer if latex formatting would be possible. Let's consider three gears: G1, G2 and G3. Now each gear has a given radius r1, r2 and r3. The problem is to find the angular velocity for each gear (denoted av1, av2 and av3). From a physics course we know that the tangent velocity v is proportional to the radius: v1 = av1 * r1. ...


2

CharacterController controller Has a radius and height that define its space occupation. (the green cage in the image). That cage (capsule) interact with othe colliders (i.e : the terrain). If the cage its too big respect the enemy shape, you see it fluctuate, because the cage bottom touches the ground.


0

Your todo can be done with, FindGameObjectWihTag ("Player") as there will only ever be one player per instance unless you're doing multi-player. Damping has no value. You need a value for gravity on the empty otherwise you have 0 gravity and you're reducing to <0 which would cause it to float.


0

What you need to do is control the rocket using steering behavior. At every frame. You want to move the rocket towards its transform.forward, it might be transform.up in the case of 2d. Then you want to lerp the rockets rotation towards the target location transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(target), ...


0

You could make a coroutine and make it delay for some time and then activate the rotation function. The spawning position may be randomized using random.range


0

While I personally love bunny hopping... As a starting point we should know the intended "Jump Speed" as a delta velocity. This figure represents the velocity increase (in the line with the "Jump Normal") during the instant of jumping once. Any velocity the player already has in line with the Jump Normal can be seen as a pre-existing "Jump Energy". This ...


0

First of all, i want to say that your question is very well written and it's a pleasure :), you would just need to remove what's not necessary in the code (audiosources, etc.) and it would be perfect. Cheers for that. For the answer, you could clamp your velocity when jumping, which would prevent you from reaching too high speeds when pressing the jump ...


0

I may have interpreted what you want to do incorrectly, but it sounds like what you want to do is have the rocket rotate to look at a point, and then accelerate if the user is touching the screen. I'm not going to help you with the touch input part, but I will assist you in the rotation and actual movement as that seems to be what you asked for What we need ...


1

It's been a while since I did anything like this, but if I recall correctly you want to test a point on the circle against the line that defines the wall, and if the point has bypassed the line (IE, the line is closer to the center of the circle than the radius of the circle), a collision has occurred. The "pushing" effect comes from blocking the ability to ...


1

The Wikipedia article on collision detection has this to say on the topic of matrices and collision detection; So we reduce the problem to that of tracking, from frame to frame, which intervals do intersect. We have three lists of intervals (one for each axis) and all lists are the same length (since each list has length n, the number of bounding boxes.) ...


0

After some time and research, I got to know that you actually lose only one physics step, and not a whole game frame. And if you're updating your physics at a high rate (you should update it at least two times faster than the expected frame rate!), then it will probably go unnoticeable. In my game I'm using a 0.008s (125fps) physics step and can't barely ...


0

{ 0.000000, NaN, 0.000000 }. NaN smell of division by zero. check AnglularAcceleration () AnglAcc = new Vector3(0f,(speed * speed) / (2f * theta.y),0f); AnglAcc.Y will be NaN when theta.y =0


0

I found a fix for this by adjusting the world update time interval. Initially the world was being once per frame updated using delta t, the time since the previous update. world:update(dt) From what I understand, by splitting this down into several smaller updates the forces being generated each update are small enough to be kept in check by Box2D. ...


2

Vector mathematics! Assuming you're using Unity, you could use the inbuilt functions of Vector2: transform.position = Vector3.MoveTowards(transform.position, target, speed); Otherwise, here's how it's done - first, calculate the direction from point A to point B: public static float Length(float x, float y) { return Math.Sqrt(x * x + y * y); } ...


1

There was something wrong with my collisionNormal method, where the left and right vectors were actually flipped. This made collisions along the x axis actually push the objects into each other. if (wy > hx) { if (wy > -hx) { /* collision at the top */ return new Vec2D(0, -1); } else { /* on the left */ return ...


1

Both ideas are actually correct, but the second code snippet seems wrong to me. If it is the same get_drag() in both cases, then it should operate on a scalar, and return a negative number. It should be something like: drag = v # No sign inversion here; get_drag() does it drag.normalise() fd = get_drag(length(v)) # Operate on a scalar drag ...


1

All free rigid bodies will rotate about their center of mass, so you're kind of stuck in that regard. However there are two options: Implement an artificial pivot (specify the coordinate that you want it to pivot about) and do summation of moments about that point. This would require a modification to existing physics fxns, or a new fxn. Temporarily store ...


0

Figured it out, here is the code that i made: float angle, speed; Vector2 newVelocity; //use sin and cos to work out x and y speed velocity.x = Mathf.Cos(angle) / speed; velocity.y = Mathf.Sin(angle) / speed; //apply the new velocity to the current object this.GetComponent<Rigidbody2D>().velocity = newVelocity;


2

For a really good and in-depth article on this subject, just read Fix Your Timestep. There's also a ton of existing questions about this subject, although addressing different angles. But in really simple terms, this is how you get a fixed physics (or anything, really) frame rate despite the rendering frame rate being unpredictable: loop check how long ...


1

To do this, firstly you need to define a physics update time period (say, evry 16ms) and then you need to handle the case of when your game runs too fast, and when it runs too slow. When the game runs too quickly (faster than your physics update period) you need to interpolate between the last physics frame data and the next physics frame data based on what ...


0

The Minimum Translation Vector is the collision normal most of the time. However, I believe that without velocity information it is impossible to get the collision normal correct all the time. Consider that you have 2 aabbs colliding. One aabb is stationary. In one case, the other aabb moves from the left and hits the first aabb. The correct collision ...


0

Converting comment to answer: Yeah it totally will. You can try and hide it through predictive animations and other things, but that's all smoke and mirrors. It will affect responsiveness definitely. How bad it is depends on your frame rate of course. It also depends on the needs of your game. A twitch game like quake would show the problem very clearly ...


-1

I recommend using some middleware, so that all these kind of things are worked out for you. Otherwise, Yes, this is a good idea, you can cheaply rule out certain intersections and avoid an expensive test. This is referred to as a bounding box. Using some middleware will mean this is worked out for you.


0

If you don't need a strictly physics based solution, bias and gain can be great for giving a nice organic (accel / decel) feel to a simple linear interpolation. http://blog.demofox.org/2012/09/24/bias-and-gain-are-your-friend/ http://demofox.org/biasgain.html


0

You could try setting a threshold from the target, and multiplying the object's speed by distance / threshold: acceleration = distance / threshold if (acceleration <= 1) { speed *= acceleration; } Here's an interactive example I threw together quickly: https://dl.dropboxusercontent.com/u/38185080/Flash/Examples/Deceleration.swf Checking gradual ...


1

Shortly after posting I tested this out a bit more and found that the assert will fail. GetFixtureA() may or may not return a fixture belonging to playerPhysicsBody. I'm now using this convenience function to safely find the fixture that I want: inline const b2Fixture *contactFixtureFor(const b2Body *body, const b2ContactEdge *contactEdge) { return ...


2

Approach B is what you want. With Approach A here's a possible problem: //You have two balls //Ball A moves //Ball A is now colliding with Ball B //Ball A and B get forces applied When in reality Balls A and B are very close but have the exact same velocity! What should happen (and what you would get with Approach B) is: //Ball A Moves //Ball B Moves ...


1

Velocity is speed and direction, and the only tricky part is the direction. Your question cuts right to that problem. This kind of vector math is linear algebra 101. However, since Wikipedia offers its usual incomprehensible notation for otherwise simple mathematics, here's a quick summary. The vector from P1 to P2 can be found by subtracting: v = ...


0

You say : Then I mul that by inverted local inertia to get angular acceleration in local space. This seems wrong, since "inverted local inertia" is "world inertia", so you are putting "that" to world space while you want it in local space ... So code should be : // oriMat: local -> world oriMat = quaternion.ToMatrix(self.ori) // put total torque in ...


0

I'd limit the movement near the edge of the platform. So, when the wheel base is stopped near the edge make the character halt, and wobble, and only if the player keeps on pushing will they go off the edge. You can control the "dismount" animation, too. Of course, if the player just pushes constantly off the edge you must honour their intent and just move ...


1

It turns out that Farseer objects can have multiple restitution and friction settings: one set for the body and one set for each fixture. I was only setting the body settings; adding settings for the fixtures solved the problem: fixture.Restitution = 1f; fixture.Friction = 0f;


0

Ok it's actually really simple to achieve. First of all as u mentioned, ur engine direction describes the path of movement. This makes it comfortable to work with. First of all, always store a vector of the direction ur moving. Next u must have a vector of the lookat of ur engine. So for now when u start moving, let's say right, the both the direction ...


1

Looks like you're mixing 3D & 2D physics. You're using OnCollisionEnter2D, which triggers when 2D colliders hit each other. But then you're using Physics.Raycast, which casts rays against 3D colliders - so it won't be able to detect the two colliders that triggered the event, or any similar colliders in your scene. Maybe you want Physics2D.Raycast?



Top 50 recent answers are included