New answers tagged

2

You'll need some persistent state and a frame counter passed in: float lightning(lightningState* state, uint64 frame){ if(!state->enabled) return 0.0f; if(frame - state->lastStart < state->flashDuration) // during flash return 1.0f; //can also have a decreasing function here based on the difference if(frame - state-...


2

I had the same issue days ago while creating a pong game. The problem was with the Velocity Threshold of the Physics Engine provided by unity. You need to tune it to get a smooth bounciness effect. This is the overall set up (i.e. 1 and 2 is already there in your project) Angular Drag and Drag of the rigidbody2d = 0 Physics2d Material's bounciness = 1 ...


2

To move a rigidbody, there's a few different tools: If it is not kinematic, use rigidbody.velocity or rigidbody.AddForce. For example rigidbody.velocity = Vector3.forward * Input.GetAxis("Vertical") * playerSpeed; If it is kinematic, use MovePosition: rigidbody.MovePosition(rigidbody.position + Vector3.forward * (Input.GetAxis("Vertical") * playerSpeed * ...


0

Your goal is to prevent them from going into each other, which means once you detect a collision they shouldn't go toward each other. I assume the sumos are circles. I wrote some pseudo code to show how to do it: # We compute how much one moves relative to the other. velocity = velocity_B - velocity_A; # If the sumos are circles the normal is the ...


0

Hi sorry I'd prefer to comment but I don't have enough reputation on this account. Your code actually looks very clean by the way, I wish I could see the rest of your code. I'm assuming your 'checkCollision' method is returning false. If this is the case, my guess is it has something to do with your call of the intersection function. Usually intersection ...


0

You should limit the speed from above as well. This most likely this is the reason why it behaves so strangely on a fast PC, it's simply too fast. Try to implement such a limitation. Let's start with delay ~30ms per one frame and see. Then I recommend to experiments with this value. Perhaps later one you'd like to add some physics and so on. With unlimited ...


1

I'm on my phone and can't provide a super detailed answer, but here goes. This answer will not cover the physics calculation that you use, only the logic. It looks like there is trash data in your loop. When evaluating a body with itself, you do not update the angle and the acceleration, it remeains to what was used with a previous body. Whatever is in ...


Top 50 recent answers are included