In traditional physics engine,we can scale the mesh collider by changing the scale in Transform property.
What about in dots physics,I've tried adding the scale property but it doesn't work.
In traditional physics engine,we can scale the mesh collider by changing the scale in Transform property.
What about in dots physics,I've tried adding the scale property but it doesn't work.
Related
I have a game where u bounce a ball with platform and u have to destroy all boxes but my code for bounceing ball its not working like I want.
It works like a real ball bounce but I want the ball to bounce like a ball in pong where ball don't fall down until it touches wall or platfotm but my ball goes in real life curve.
What I thing with curve is like when u kick a ball in the air and goes in curve but I want it to go unlimitly in flat line to the wall andbounce in a random direction.
Someone have any code ideas?
Make a physics material like the one below and place it on any surface that bounces. It is enough for your ball to have a Rigidbody with drag 0.
Also uncheck gravity to get the following result:
Basic Force Script:
After adding Rigidbody to the ball, you can use the following script for the initial force. Obviously you need more advanced algorithms for further development.
public Vector3 force = new Vector3(80, 40);
void Start() => GetComponent<Rigidbody>().AddForce(force);
Pong/breakout style physics is simpler than you might think.
The balls have no gravity applied to them, so all you need to do is apply a constant velocity to the ball.
When it collides with an object, you would flip the velocity on the axis it collided.
For example:
ball is travelling up at 60px/sec, and horizontally at 120px/sec, at 60fps.
You add (60/60)=1 pixels vertically every frame, and (120/60)=2 horizontally.
It hits a wall, so you flip the horizontal velocity to -120px/sec.
Now it's still going up, but in the opposite direction horizontally.
If it hits a ceiling, same thing but flip the vertical velocity component.
If you'd rather it go in a random direction:
calculate the magnitude of the ball's velocity sqrt(vx^2+vy^2)
find the angle the wall is facing
pick a random angle within 180 degrees of that angle
use trigonometry to get the x/y components of that angle, and multiply by the magnitude.
Don't subtract/add a constant value to the velocity every frame, because then you'd be applying gravity, which isn't what you're looking for.
I make a 2D game in Unity. I have a player with BoxCollider2D and Objects with BoxCollider2D and the player can't go through these Objects like it should but when the player walks from down to the top (topdown PixelRPG) Than he got blocked very early. I will try to show it in the pictures. I tried to change the size of the colliders the layers and more but can't find a solution. ProblemCollision2DChest
Collision2DNPC
Collision2DWindow
NoProblem
NoProblemswithObjects
ProblemAgainfromdowntoTop
From my experience, it looks like you simply need to resize your BoxCollider2D to fit the player.
You can either use the Edit Collider button, and in the Unity viewport you can click and drag to change the size of the collider, or change the Size value in the inspector. Since your collider seems to be too large vertically, change the Y value to be smaller.
I have a Camera placed on Position(0,0,0) and Rotation(0,0,0).I want to instantiate a canvas (dynamically) in the FOV of the camera and I want to keep the aspect ratio of the object even if the Z index is changing.
To be more clear I want the canvas to cover the same area at Position(10,5,0) and, for example at Position (10,5,50).
How can I achieve this goal?
I imported an fbx cube from blender with a lot of vertices to Unity. I added the constraints and set the sphere collider to my sphere game object. The problem is that regardless of the sphere's mass and other Rigidbody settings, the sphere still penetrates the cloth even if i set the stretch and bending stiffness both to 1. I tried tweaking other cloth settings but to no avail. What should i do please? Thanks.
Cloth Issue
I have a dynamic mesh which is created and updated dynamically according to the game,and it has many vertices. However when I use it as a mesh for its collider, I get the warning that it has more then 255 polygons. I read it is what slows the game. However the mesh has to be very flexible and growble, and it has to detects collisions. How can I optimize it in runtime foe the collider which has only to have the current approximate shape of it?
I would recommend using capsule colliders. When you expand the width of the snake, scale the width of the colliders. When you add length to the snake, add another collider onto the end. This way different parts of your snake can have different sized colliders. Depending on how much the width varies you may need to add more or less colliders to approximate its shape.
But it's always better to have many primitive colliders than one very complex mesh collider.