New answers tagged

0

One of the major elements I was struggling with in my scenario was the over-rotation from the Quaternion.FromToRotation() method. I noticed that it gave small angles even when an individual Lifter had not moved (e.g., when From rotation and To rotation were identical). I had focused so much on the moving Lifter I did not notice the non-moving Lifter was ...


0

After following @DMGregory 's suggestions in the comments I have reached the following conclusions. If you set a physics material to a Rigidbody2D, that material will apply. But if you also set another Physics Material to a collider in the same GameObject, this will override the Material in the Rigidbody2D. Apparently this is meaningless when you only have ...


0

Trying to track displacement/deltas each frame is probably making this more complicated than it needs to be. A much simpler solution is not to use deltas, and just update current position/rotation each frame based on the lifters. Here's a simple example: public class LifterManager : MonoBehaviour { [SerializeField] private Transform lifter1; [...


0

It sounds like you should use trigger colliders and a little bit of manual physics to achieve what you want. With this approach, you can place trigger volumes over portions of the track rather than having to break the track into tiny pieces. For example, add a new GameObject with a box collider to the scene. In the box collider's Inspector, check the "...


0

With the help of DMGregory I solved my problem. The way I chose is to set "Freeze Rotation Z" of the Regidbody 2D via the inspector. An other way is to increase the angularDrag of the Regidbody 2D via the inspector to e.g. 10. This works too: void Start() { m_rb = GetComponent<Rigidbody2D>(); m_rb.freezeRotation = true; } Also does: ...


1

I will assume this question is about 3D SAT which I find has alot less resources than 2D.. I have been struggling with this for the past week. I have face contacts down but not Edge cases. When you are testing your various axes keep track of which has the minimum overlap, that is your contact normal and penetration depth. Contact points are where it gets ...


0

It's less a matter of what data is passed, though that which can be made deterministic would be better so, and more a matter of how often that data must be passed. Michael Abrash talks a bit about perceptual latency reduction: http://www.jagregory.com/abrash-black-book/#how-we-spent-our-summer-vacation-after-shipping-quake In the subsection on QuakeWorld. ...


0

I have not implemented a network strategy myself, but I have already read some related texts and thought about network solutions for my game engine project. So maybe I can give you a small overview. I recall reading that in Team Fortress 2, the computer tracks the trajectory of every projectile including every bullet, rocket. It seems like that would ...


3

Set the pickup to be on a layer that interacts with the ground only, not the player character. Give your player character a child object that represents their collection radius. Give it a trigger collider, and set just this child object to be on a layer that interacts with the pickups, leaving the root of your player character on its original layer. Now your ...


0

The bottom of This page provide clear equation and explanation of 2D circle collision. It's might help. Note: As you see in that page, you collision equation only work in impact line (normal of contact surface) but the tangen velocity still the same cause by no serface friction. the general idea is to transform velocity to tangen and normal velocity. update ...


0

Tomake 2 bodies (planets) move together naturally. you need to make it conserve momentum. In this case you need to see inelastic collision When collision happen, both object need to be merge in to single object. velocity of new object can be obtain by v_x = (m1v1_x+m2v2_x)/(m1+m2) v_y = (m1v1_y+m2v2_y)/(m1+m2) Additionally you should make it conserve angular ...


1

You can't just "flip velocity over y". To further that point, its obvious to see on the left and right sides of the box you would not flip over y, but instead flip over x. On the corners you need to flip over a diagonal direction. This is where it becomes less obvious how to flip it. But it's still quite easy: What you need is a function to flip ...


0

Maybe you could do something like this: Let's say we have planet A and planet B. When A and B collide, a function is executed, and we can use it to set some values. First we decide which planet is going to be the master and which is going to be the slave. Lets say A is master and B is slave.I'll explain it later. Then we find the vector between A and B Then ...


2

Unity will call your OnTriggerEnter or OnCollisionEnter callback only if it is a member of your type, not a local method buried in another function. It looks like you might want to use a physics query here instead, like Physics.OverlapBox. This lets you check for overlapping physics objects in a particular volume of space on demand, using layers or trigger ...


2

There are three basic approaches to this problem. Render Less This includes techniques that allow you to skip rendering polygons that are not visible, while maintaining a high polygon count for those that are visible. It might include backface culling, frustum culling, visibility culling; LOD techniques might also fit here. Render More Efficiently Batching ...


0

Thank you for your answer. I think i found a solution. The solution is reduce the FixedTimestep into 0.01 instead of 0.02(default). I think this will make the physic much more precise(Since every thing on pitch happen in 8x8 grid).


1

So I found out the answer thanks to Zibelas! I forgot to apply moveVector to my movement. //Move the player myBody.velocity = moveVector * moveSpeed;


2

First disable the gravity of the objects rigidbody when it gets spawned. You can do that in the inspector of the prefab for your projectile, or you can do it with code. For a 3D rigidbody you do that with: GetComponent<Rigidbody>().useGravity = false; For a 2D rigidbody you do that with: GetComponent<Rigidbody2D>().gravityScale = 0f; When the ...


1

Before Trowing object just disable the gravity of the object and upon reaching to the destination or by reaching the velocity of the object to 0 or nearly 0 then reenable object gravity so that object falls down freely. I hope this will achieve the required effect. (Converting comments to an answer so that next person in need can find it easy). Thanks to @...


0

https://docs.unity3d.com/ScriptReference/Rigidbody-rotation.html GetComponent<Rigidbody>().rotation = Quaternion.identity; This command is about as precise as you are going to get. If this does not solve your problem then we need more details about what kind of "difficulty" you are facing, as Phillip suggested in his comments.


0

Following on DMGregory's comment, and some late night / early morning ideas, I tried something a bit different today. Previously I'd tried: Every "turn" allow X percentage of a tile's gas to move, split evenly between neighboring tiles who had less of that gas. This worked, but resulted in slow movement. Removing that percentage limit and instead allowing ...


0

I tried to set up a demo project to test around and found a simple approach based on rotation constraints as suggested by other users, and the AddForce() function as you needed it. I applied a zero-friction material to both the capsule and the cube, and later found a nice value of 0.2 for one of the two only in Average combine mode (alternatively: 0.1 for ...


1

So here is my thought on the issue, there may be an easier way but that doesn’t matter you have to start somewhere. I’m assuming you are using a ray cast in order to check if the player is close to the ground, so what you can do is use RaycastHit.normal() to get a new vector that represents the normal of the object. With this new vector you can calculate ...


Top 50 recent answers are included