#⚛️┃physics

1 messages · Page 76 of 1

snow surge
#

Vector3 is pretty much just a container for 3 floats, with some extra functionality

#

So it can represent a position, or direction

flat palm
#

That's what I figured but what's confusing me is how does it obtain magnitude if it is just an arbitrary point

snow surge
#

Distance from 0,0

flat palm
#

Ahh that's the part I was missing

snow surge
#

It's calculated as sqrt((x^2)+(y^2)+(z^2))

flat palm
#

okay I see thank you

tired hatch
#

hi..
i dont know much about unity but i wanted to create a scene so that i could visualise my physics problem(high school student)...
can anyone help?

unique cave
#

I guess you're not going to get very realistic results with only angular drag, drag, friction and bounciness. Unity doesn't simulate rolling resistance by default. Angular drag can be used to do sort of same effect but (as far as I'm not mistaken) it's actually not the same thing. If you want somewhat physically correct behaviour, you would need to implement the rolling resistance yourself. In this part I may be completely missing but I guess rolling resistance is just some constant (force applied to opposite side of movement that speed doesn't affect, or maybe It's proportional to speed I have no clue) and angular drag is like air resistance that happens when object rotates (imagine sheet of paper rotating fast) which is either proportional to the angularVelocity or squared to the angularVelocity depening on the speed. Because billiard balls are perfectly round, there should be no angular drag at all. So I'd try to add some constant force (the force should be clamped somehow tho so it doesn't start moving backwards when it's about to stop) in the opposite side of movement of ball, remove angular drag and see whether or not it looks good.

clear dew
#

Hi, does anyone know how is add force at position calculated into add force and add torque? I tried looking into physx documentation but it's not there.

stuck bay
unique cave
stuck bay
# unique cave no problem. good luck with it 👍

I managed to get back and although I haven't tried out the constant resistance yet (though I'm pretty sure that should work as long I deltaTime it on the physic ticks), but with some further study of billiard physics and some trial and error, I've managed to get the ball physics pretty damn close to real cuesports. I've even added the ability to put horizontal and vertical spin on the ball using AddForceAtPosition using a Vector3 multiplied by the radius of the ball. I'm so happy!

#

Does this look correct? First shot is backspin, second is topspin. Ball is slightly off centre to prevent it from just going straight. Obviously no rolling resistance yet other than the friction that slows down and corrects the spin speed.

stuck bay
#

Sidespin also seems to work fine, but I know less about that. Cue rebounds off balls and cushions as I personally expect them too, though.

jovial wraith
# clear dew Hi, does anyone know how is add force at position calculated into add force and ...

I'm assuming it does it the same way you would calculate the effects of applying a force to a rigid body in real physics. You decompose the force into two components -- a component that points directly toward the center of mass and a component that points perpendicular to the first force. You then apply the force pointing toward the center of mass to the rigid body (as a force) and apply the force pointing perpendicular as a torque.

clear dew
#

@jovial wraith thanks

olive sigil
#

So, im trying to have a system where you control the head of a snake, and the body segments just follow along, right now im trying to do it with configurable joints, but i just want the prior segments to follow, and to not hinder movement of the head

#

effectively i want the tail to act like a trail-renderer, but with a trigger collider so i can check for intersections, and an actual mesh skin instead of a line

civic field
#

how to add a force to an object in a way that changing the object's mass wont affect the percieved movement from that force

#

aka apply a force thats not affected by mass

timid dove
#

Or, if it's 2D, just use the normal ForceMode2D.Force, but multiply the force by the Rigidbody's mass.

analog glen
#

Deceptively complicated issue here. Wonder if anybody has a neat idea for a solution.

My plane has a Rigidbody attached at the top level with a bunch of colliders in the children.
I'm detecting collisions and if collision impact is > a certain threshold we call CrashPlane(). So far so good.

I want that threshold to be higher if you landing on the *wheels * (a bit of give in the suspension) as obviously you can land a plane on wheels much harder than upside down, for instance. But OnCollisionEnter(Collision collision) appears to have no way to know which child Collider called the function 😓

TL;DR how can I detect *which *child collider has called OnCollisionEnter?

shell adder
analog glen
#

Ah! Thank you! Somehow missed that that function needed to take an int, and then convinced myself it wasn't going to return me what i wanted. Thanks again ʕ•ᴥ•ʔ

river cape
#

It happens when edge of a box collider collide with something. I only found one solution which works for me. I've replaced box colliders with capsule colliders and that's helps me a lot. But also the size of the collider matter. And changing the detection type on rb to continuous dynamic should help.

timid dove
low narwhal
#

How should a cloak or cape be handled? Should I do any rigging in blender, or is this done in unity?

spiral tulip
#

you may have to make the animation in unity but you should be able to rig in blender

austere ivy
#

https://www.youtube.com/watch?v=M3iI2l0ltbE so i made a infite terrain with the scripts used in this video but i cant seem to get the physics working, all the chunks have a a mesh collider and my player has a capsule collider

In this coding adventure I try to understand marching cubes, and then use it to construct an endless underwater world.

If you'd like to support this channel, please consider becoming a patron here:
https://www.patreon.com/SebastianLague

Project files:
https://github.com/SebLague/Marching-Cubes

Learning resources:
http://paulbourke.net/geometr...

▶ Play video
stuck bay
#

The Dynamic Friction only seems to affect the sliding friction of a ball, not the rolling friction. Basically, it will slow down until it reaches a certain speed (which is different depending on how fast the ball was impulsed at) with constant angular acceleration. Once this speed is hit, the ball will stop slipping and begin rolling, but the friction will no longer do anything.

I tried manually adjusting the angular velocity with Fixed Delta in FixedUpdate, but there were 3 main problems:

  1. The angular deceleration was about half or more than what it should have been. If I put in -10rads/s, it only really goes down by about 4-5rads/s, so I have to use -20 to get the effect I want.

  2. The ball will eventually reach a linear and angular velocity of 0 just by lowering the angular velocity, but for some reason the ball will start to gain limear velocity in all directions. Despite having something like a speed of 3m/s, the ball stays perfectly still as it should, but stays awake for no appparent reason. I couldn't find a way to force the rigidbody to sleep, doing so through multiple ways gave the ball a 50% chance of not firing.

  3. There is no angular deceleration while the ball is slipping, only when rolling. This might be correct behaviour and isn't a big deal in my eyes, just an observation.

I've really been tearing out my hair over this, once I get this bit done, the rest should be easy enough for me. There must be loads of games that have semi-realistic ball physics, I can't believe I'm struggling so much with this.

stuck bay
#

Nevermind, I found an equation on Wikipedia which might help me, so I'll try that.

#

Well actually, that just looks like Drag.

#

But if I use Drag the ball will never seem to stop, just move very slowly for a long time.

#

Unless I just put in my own minimum speed, I guess.

#

Actually, maybe it's not the same as Drag. I'll mess around with it.

teal pendant
#

i have some very annoying issue in my project.
I have a floor which is a plane and has a mesh collider enabled on it.
when i place a rigid body cube with use gravity, the gravity works, but the cube keeps falling down and down

daring furnace
teal pendant
#

this is of the plane

daring furnace
#

try setting the CollisionDetection to Continuous?

#

I'm not sure though, I dont use 3d much

teal pendant
#

that still didnt work 😦

daring furnace
#

the cube falls through the plane, that's the problem, right?

teal pendant
#

it was the Collision Matrix

#

once i corrected that, it just worked

daring furnace
#

oh.. ok. In the future, please don't crosspost. delete your message if you're already being helped in another channel

teal pendant
#

ok sorry

waxen steeple
#

I have a simpel rigidbody movement script. for jumping i use

this.Rb.AddForce(Vector3.up * JumpForce, ForceMode.Impulse);

But my player just "teleports" to the highest point of the jump and than falls down.
Is there a way to do this a little bit smoother?

waxen steeple
#

something about 30f i think, but if i lower it, i wont jump at all...

waxen steeple
#

in fixedupdate

daring furnace
#

sounds about right.. sorry, no clue

desert wave
waxen steeple
#

not yet ... 😭

#

im playing around with values, but it doesnt work

desert wave
#

or your pc

#

try putting your script on a new gameobject

#

with rigidbody non modified and a collider

waxen steeple
#

i will try

desert wave
#

and ping me

shut wind
#

Hi, I have a robot and have simulated it with an articulation body. The wheels are attached to the chassis and are revolute joints with sphere colliders. The articulation body for each wheel is locked to the axis I want. Im having trouble though understanding the force limit and how it is applied. Ive set it to a very small number because I was getting loss of traction when applying an instant 100% target velocity but I assumed that force limit would limit the acceleration of the wheel. Any suggestions?

#

I have the drive configuration set to 0 stiffness, 1 damping, 0.1 force limit, 0 target, and target velocitt is set to 360deg/s when the user presses W

#

Also another problem im having is when the robot is on a slope it will roll down the hill even though target velocity is set to 0 (no input from user) so my understanding is that the drive motor should apply a force to stop the joint from rotating but that seems to not be the case

waxen steeple
#

@desert wave Tried it with a simple capsule + rigidbody, the same problem 😭

desert wave
waxen steeple
#

@desert wave hm i will let it test a buddy 😉

desert wave
#

and have you tried restarting unity

waxen steeple
#

i made an extra scene for it, an restarted unity several times 😉

#

Buddy has the same problem...
Can i cheat a little bit and add an Acceleration over a few milliseconds? maybe it become a little bit smoother ...

timid dove
waxen steeple
#

@timid dove i reduced my movment code a little. still the same problem...

flat pewter
#

I'm trying to make a cape with the cloth component, but when I click the "edit cloth constraints" button, I'm not seeing any spheres appear on my cape, nor am I getting that little window in the corner of my scene view which can be seen in this tutorial. Does anyone have any idea what might be wrong? I have gizmos enabled. https://www.youtube.com/watch?v=FkEqFvqpyfE

In this video, I talk about Unity's Cloth System and how you can make some sort of Hammock with the Cloth System I also talk about all the variables or parameters that are on the Cloth System. If you enjoyed this video or if it helped you out in any way make sure to hit the LIKE button and if you want to continue to see more videos like this do ...

▶ Play video
#

Hm, after restarting Unity, now I get the window and the spheres but the spheres are very large making it hard to edit them because they're alloverlapping. Is there a way to adjust their scale? Adjusting the 3D gizmo scale doesn't change them at all, and disabling 3D gizmos does nothing as well.

#

Nevermind I figured it out. For whatever reason the size of the vertex selection spheres is called "constraint size" and adjusting that to 0.01 made them reasonably sized.

stuck bay
#

I wonder, what in unity physics does make two coliding objects with rigid body always fly off in different directions?

#

If the starting position of objects, mass, and speed are all the same, I would imagine the result of each collision would always be exactly the same

timid dove
stuck bay
# timid dove What does your vehicle movement code look like

just ```using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    // Move the vehicle forward
    transform.Translate(Vector3.forward * Time.deltaTime * 20);
}

}```

timid dove
#
  1. transform.Translate mostly bypasses the physics engine
#
  1. Doing this in Update means that it's going to be slightly different each time because your framerate is not always the same
#

So the exact amounts you translate forward will be different

#

Which means the depenetration by the engine will be different

#

Because you will overlap colliders differently each time

#

An immediate fix would be to simply move your code into FixedUpdate

#

A better fix though would be to learn about actually moving your object via its rigidbody (also in FixedUpdate)

stuck bay
#

Thanks, that makes sense

orchid blaze
#

Hey,

I made 3 characters.
1: simple animator with ik
2: simple animator with motion matching
3: ragdoll with animator copy motion but here is the problem.

With the case 3, the copy motion, balance is done, but as you can imagine foot hit too mutch floor and did some times moonwalk... It's normal because i didn't do the foot ik gestion.

So what is the best way to get 50/50 rag motion?

Procedural walk and disable foot rag?

Recalculate like ik at x of animation?

Or other thing?
🙃

flat bone
#

Hello everybody,
Someone has used the Unity packages for integration with ROS?
For robotic simulation.

timid dove
#

<@&502884371011731486> ^

lethal owl
#

what settings should I add to my RB to make it behave like in 0g and in a vacuum?

wide nebula
#

Turn off gravity and away you go.

lethal owl
#

thats all? great

wide nebula
#

That's basically what 0g is. 0 gravity.

lethal owl
#

i know, i was wondering maybe some settings were needed for the vacuum part, but i guess unity doesnt count that in anyways?

wide nebula
#

Well, you can set the drag to zero as well yeah.

thorny basin
#

I'm making a hand with articulation bodies, but sometimes an articulation bugs out completely, somehow its rotation changes referential

#

I should point out I'm using an articulation per phalanx

#

Is it even viable to have such a setup on a realtime physics engine ?

native yacht
#

So i have this code.

#

and it send false when iam on ground (red small line) false = red

#

and it send true when i jump (small green line)

#

With is oposite + it wont send tag to footstepsystem :ä

granite flame
#

not sure if this is the right channel, but I'm having issues with collisions. Player can move right through walls, and I have tried changing the collision detection mode from discrete to all others. Anyone know?

daring furnace
#

You need to use physics based movement for it to respect colliders

granite flame
#

I am using rb.MovePosition

daring furnace
#

Okay sounds right

#

Do the walls have a non trigger collider

granite flame
#

yep

daring furnace
#

No idea

stuck bay
#

not entirely sure if this belongs here but would a capsule collider require more resources than a box collider?

desert wave
#

It won’t make a difference

stuck bay
#

alright

timid dove
#

The math might actually be simpler 🤔

#

But both are very fast

desert wave
timid dove
#

capsule collider overlap checking is surprisingly simple - conceptually it's all points within a certain distance (the radius) from a line segment (the height of the capsule)

desert wave
#

forgot about rotations

timber python
#

Hi, I've got a question about particle collisions, should I ask here or in vfx channel?

primal raft
#

Hi , i need some help for this point.
I'm developing a VR Hand, and I'm trying to get the velocity or magnitude of the movement, or speed.. (doesn't matter as long as i get something...)
but the velocity displayed in the debug of the rigid body is still zero.
The only way i can get something is when i activate Gravity, but only for Y

unique cave
primal raft
#

the hands are moved following the controllers trackers

unique cave
#

I have no idea what that means (I have no exp with vr) but if you don't use physics to move the hands, you can't use .velocity to measure the speed. You can probably keep track of the last frame hand position, measure the distance to that and divide that by Time.deltaTime to get the speed at the moment.

timid dove
#

It's probably either just setting the positions directly (teleporting it around), or best case scenario it's using MovePosition

#

neither of those things sets the RB's velocity

#

to get the velocity you'll have to record the position each frame and compare it to the previous frame

#

then account for how long that movement took, and you can easily calculate the velocity

fathom coral
#

Hey Everyone,
I am working on a project and need to create a unicycle in unity. Should I create the frame and wheel separately in Blender and then add the physics in unity? Then when doing the physics what kind of component would I use to get a physically functioning joint from the wheel to the frame?

timid dove
#

and maybe a hingejoint?

#

I'd do the wheel and frame as separate meshes (though could be in the same blender file)

fathom coral
prime flower
#

Anyone know what general performance of PhysX articulations are?

#

I know it’s obviously dependent on a lot of factors, but can’t seem to find anything about performance

serene jolt
#

Hello. I'm trying to implement a system where the enemy and player colliders can overlap and don't 'interact', but I can still detect OnCollisionEnter or something similar for hit detection. Does anyone have a moderately straight forward solution to this?

serene jolt
#

I still want the general functionality for my enemy collider though so that it can walk around on surfaces and stuff so I had been using IgnoreLayerCollision, obviously that doesn't work though. I had also tried to child a trigger collider to my enemy object and just have a regular collider and a trigger but they seem to conflict that way

#

Maybe I just need to screw around with it more

bleak umbra
#

layers, triggers and non-triggers are all you need

serene jolt
#

I guess I just need to have it configured correctly

bleak umbra
#

its a very common case what you are describing, so if it isnt working for you, there may be an error in your setup

serene jolt
#

I figured, thank you 🙂

timid dove
# serene jolt I figured, thank you 🙂

Basically you'll need two separate colliders for either the player or the enemy. One that is a trigger collider for the non-physical interaction, and one normal collider for the physical interaction

floral blaze
#

Hello I was wondering if someone would know why my player object in my 2D game has collisions with the my tiles top and bottom but not the size. I'm using a Box collider 2D and RigidBody2D for my player, and a TilemapCollider 2D for the tiles. I've looked through Documentation, Tutorials, and tried my best to fix the problem on my own.

#

Able to stand on top vv

#

Passes through the sides vv

timid dove
floral blaze
#
float movement = Input.GetAxis("Horizontal");
transform.position += new Vector3(movement, 0, 0) * Time.deltaTime * MovementSpeed;
#

This is how I move my character

timid dove
#

this method of movement ignores the physics engine entirely

#

it will gladly teleport you directly into a wall

#

because it literally just says "set the position to this new position"

#

there's no checking for whether that position is inside a collider or anything

#

If you want collisions to work nicely, you need to move via the methods on your Rigidbody2D

floral blaze
#

Yup that was it haha, that makes sense. Thanks for the help! 🙂

tender patio
#

I have an issue where my CapsuleCollider/RigidBody gets stuck on the edge of a BoxCollider when moving slowly. The CapsuleCollider should just fall off the edge, but just gets stuck there, even when using AddForce. The CapsuleCollider does slide along the edge if enough force is applied, but will not fall off,even when going around the corner of the BoxCollider. Has anyone run into this issue?

shell adder
tender patio
shell adder
shell adder
#

could you show your isGrounded method

tender patio
shell adder
#

this could lead to it not being grounded if the collider is half way off the edge

tender patio
shell adder
#

or a boxcast

timid dove
# tender patio https://paste.ofcode.org/329MkTGLYqffRPs3C68SsKf
            if (Math.Sqrt(Math.Pow(rb.velocity.x, 2) + Math.Pow(rb.velocity.z, 2)) > maxVelocity)
            {
                rb.velocity = rb.velocity.normalized * maxVelocity;
                rb.velocity = new Vector3(rb.velocity.x, y, rb.velocity.z);
            }

Change this to:

Vector3 horizontal = rb.velocity;
horizontal.y = 0;
if (horizontal.magnitude > maxVelocity) {
  horizontal = horizontal.normalized * maxVelocity;
  horizontal.y = y;
  rb.velocity = horizontal;
}```
#

right now you're including the old velocity in the normalize calculation

warm crest
#

i just did a simpler thing

#

make the hitbox bigger

desert wave
#

Or that too but now your player is gonna be easier to kill

granite vapor
#

Hey guys I made my moving platforms rigidbodies so they would handle the player being on them automatically, problem is that it doesn't seem to work all the times, for instance when they start moving (in this example we are referring to an elevator) the player will start falling, then once it touches the platform again it will stick (with an occasional unstick again while moving). Does anyone have a solution in mind?

desert wave
granite vapor
timid dove
#

e.g. you're setting transform.position directly

#

or using transform.Translate

granite vapor
#

im not

#

im using MovePosition

granite vapor
timid dove
granite vapor
#

Yep

desert wave
granite vapor
# desert wave do you need the elevator to be a rigidbody?

I was implementing moving platforms for my character and i've read around that simply making the platform a rigidbody too is the simplest way to handle interaction without having to deal with bunch of other issues. Ill watch the video tomorrow as rn its quite late

wraith junco
#

You can create a trigger that sits above your platform that tells the game when to parent/unparent the character from the platform

sharp orbit
#

so i am using rigid body on my player to move but I have a custom 3d model and i dont know how I can add a colider for it and mesh collider wont work. I tried capsule colider but the player fell and rolled

desert wave
#

or use more colliders

sharp orbit
#

ok

granite vapor
olive sigil
#

I feel like there is a way to do this with joints, but i just cant get it to work,
I want to have a line of objects that follow each other, they have a "preferred" distance, .2 units, and will stretch to a max of .25 units, and if the one in front of it slows down too much, they will collide

#

spring joints just seem to add way too much energy into the system and have it blow up, or dont get pulled fast enough
in 2D the Max Distance Joint seems like what i want, but i dont see a 3D equivalent

#

so, the end result is i want them to follow eachother perfectly, the way im checking this is by having the leader have a trailer renderer and i want the "children" to follow that trail

hot dove
#

Using this code to add knockback to a gun that i've made, but for some reason when the player reaches ~40 y velocity, they keep accelerating upwards infinitely, even though no code is adding any forces. Any idea as to why this might be?

#

I did find out that if I use my double jump, the player will fall back down (it sets the y velocity of the player's rigidbody)

desert wave
serene forge
desert wave
#

and is there code and show the inspector of the wheels

serene forge
desert wave
serene forge
#

yes

#

heres a pic of the wheel inspector

desert wave
#

Then you are using 2d physics

#

3d physics are the ones that doesn’t have 2d on their name

serene forge
#

ok

#

well do you know what to do?

desert wave
#

I said to send a video of the wheels when the game runs and see the inspector

#

Because it can be the scale or rotation

versed robin
#

how to i change the collider of the particle?

#

right now it is the sphere but i want the wood plank collider

#

i dont see an option

#

in the renderer it is the wooden plank

#

ok i found it

#

under shape

versed robin
#

nvm i dont think that was it...

#

so does anyone know how to change the collision shape of a particle in a particle system?

unique cave
# serene forge

This happens because the local space of wheel is stretched along some axes. Every parent of the wheel should be scaled uniformily.

gilded sparrow
#

I'm trying to modify a chara controller to exclude collision if the hitInfo.collider.name is the same as the player, for a "selective access door" purpose

But this CC uses Physics.CheckCapsule for the last sanity check and this thing has no collider/object callback, so... is there alternative?
I guess i could switch this to OverlapCapsule and check that

hazy sleet
#

i'm doing a car game and i'm using wheel collider for wheels but there is a problem, the collider doesn't work at all, the wheel doesn't collide and just go through the ground, can anyone help?

#

i solved this

#

now, why the car is not moving?

timid dove
sage wolf
#

Im doing custom Physics simulation, soft body with spring mass model, and its working fine, but i have a question

#

Is it possible to do custom Collision detection ? I have to detect collision of the particles with normal game objects, but the particles are not normal game objects, i have to manually check if a certain position is inside ANY colliders, because i cant use OnCollisionEntry if my particle is not a gameObject

#

So my question is, is it possible to get all colliders of a scene so i can check all of them for collisions ?

bleak umbra
# sage wolf So my question is, is it possible to get all colliders of a scene so i can check...

Naively you can just find references to them and iterate over a list of them (i.e. FindObjectsOfType<Collider>())... but without some effort towards optimising that (e.g. search in a BVH or something similar) that collision test will be very inefficient. More efficient would be to use internal physics via Physics.Overlap_() and Physics.Check_() to find colliders in a defined volume.

sage wolf
#

thx

hot dove
#

I added a velocity cap at 30, and it doesnt continually accelerate anymore, so I think its an issue with unity's physics system?

sage wolf
#

guys, anyone here got experience with soft body physics im so close to giving up this shit is frustrating asl 😭

bleak umbra
strong comet
#

Hi guys! Im trying to let dice fall onto a moving platform. I cant manage to get the dice to stick the the platform once fallen, they just float on the position they landed.
What I tried was to give the platform a physics material with maximum friction, this didnt work. No rigidbody settings on the plattform did the trick as well.

Anybody got another idea? Thanks 🙂

timid dove
strong comet
#

This is how I spin the platform. Maybe thats wrong?

timid dove
#

modifying the Transform directly bypasses the physics engine entirely

#

no friction force will be imparted, your platform is essentially "teleporting" into its new position each frame

#

You can use Rigidbody.MoveRotation, and you should do it in FixedUpdate

strong comet
#

Thank you, I will try that!

timid dove
#

it should basically be something like:

rb.MoveRotation(rb.rotation * Quaternion.Euler(0, RotationSpeed * Time.fixedDeltaTime, 0));``` inside FixedUpdate
strong comet
sour jungle
#

I have a bunch of 2d prefab tiles. each has a static rigidbody and a boxcollider set to trigger. I am attempting to do a overlapsphere but am never getting any colliders back. Any ideas as to what may be going wrong? private void CheckColliderMoveTo(Vector3 target) { Vector3 targetPosition = transform.position + target; Collider[] hitColliders = Physics.OverlapSphere(targetPosition, .2f); if (hitColliders.Length > 0 && hitColliders[0].CompareTag("Tile")) { transform.position = hitColliders[0].transform.position; } }

#

target is a basic vector3 based on move direction. ie new Vector3(1,0,0).

timid dove
#

3D colliders in particular

#

and where is the GameObject this script is attached to?

#

Is it anywhere near the colliders?

#

I'd guess you're probably just using 2D colliders. Physics.OverlapSphere is for 3D

sour jungle
#

Ah. That is probably it. Thank you very much

#

the 2d colliders

#

Yep. that fixed it.

fast path
#

Hey guys, for some reason my player can pierce and squeeze through walls, even though collisions are somewhat working? I have collision detection on Continuous and I'm using Rigidbody.MovePosition (MoveRotation for rotation) in FixedUpdate for movement. Both the player and walls are just using box colliders. Any help would be appreciated, ty

obsidian flame
#

Hi all, I've been learning unity for quite a while now and now I'm working on a simple car parking project, I'd like to know how you guys typically handle/ would handle the mechanics of checking if the vehicle has been correctly parked, I have tried with bounds.Contains but this doesn't seem to work, does anyone have a script I can use or otherwise a direction I can start following?

hazy sleet
obsidian flame
#

I tried something like that but I'm getting some weird things going on, sometimes the position of the car is always the same position as the trigger, I don't know but thanks anyways I just wanted to hear what the best approach would be

shell adder
fast path
#

Yeah it's on Interpolate

shell adder
#

oh wait i don't think it actually detects collisions

shell adder
fast path
#

It seems to be detecting collisions just fine, just not sticking to them

#

I'll look into changing the velocity though

shell adder
#

you can use AddForce

fast path
#

Wouldn't that constantly increase the force and make it go faster?

timid dove
#

If you call it constantly, sure

#

If you add less force when you get up to speed, or add a proportional drag force, then no

fleet jay
#

How can i make this bike able to move forward by only force made by wheels? Wheels have rotator script which rotates their transform by x amount in time. When wheels are made, the bike keeps jumping because of gravity but doesn't go forward.

#

Bike
-mesh collider
-rigidbody

Wheels
-mesh collider

#

The hierarchy is shown on the video. The wheels are Front Wheel Position and Back Wheel Position.

timid dove
#

Rotating transformms isn't going to produce any kind of force

#

it just teleports them to a new orientation

fleet jay
#

Will Wheel Collider work even if it has irregular shape? Wheels are made by drawing canvas in left lower corner so user can draw everything.

timid dove
#

no

#

you probably want to attach your wheel to the bike with something like a hinge joint

#

and then spin it by adding torque to it

mighty sluice
#

"rigidbodies are supposed to act like one big collider" - this is true for collision events but evidently not triggers

#

i am simply trying to answer your question?

#

please ignore me then, I'll not answer anything else?

desert wave
#

does it only happen when both children are triggers?

#

hmm what about a raycast shape? @subtle meadow

#

the first part is wrong, raycasts are not expensive a trigger is more expensive actually

#

well in my google search no one actually used a raycast shape, just the raycast and well it ended up with try both methods

#

do you have a source?

visual cobalt
desert wave
#

still using normal raycast and not shapes, might be better to try and tell me

lapis heron
#

Hello, I'm trying to more or less accurately simulate a Packaging Box used in the industry. It should fold to an almost flat position and extend to a cube shape. I have tried using Hinge Joints but with little success as the physics are very jiggly and don't work at all. I have tried using Inverse Kinematics as well but I'm struggling to make it collide with other objects to make it realistic. I'm quite new to Unity so if anyone has any idea of how this could be done it would be great. Thank you!

tired island
#

Hey guys! I'm trying to make a 3d game that's tiled, similar to minecraft, but I don't really wanna do cubes - I might have to resort to it for ease of programming, but for now, I'm wondering if there are any other regular 3d shapes that tesselate perfectly? they can rotate if they need to, as long as they tesselate with no gaps and with no shapes involved. if there - arent any - then tell me about pairs of shapes that tesselate when put together! i cant see antything about this kinda topic online, so if anyone has any expeirnece, id greatly apprciate the input!

timid dove
tired island
#

oh, thank you so much praetor thats the answer i was searching for

past phoenix
#

I have a question about WheelFriction curve - how do i interpet units of slip - for example if extremum slip is defaulted to 1 and asymptote slip is defaulted to 2 - does that mean it has 1% slip at extremum and 2% slip at the asymptote? I dont know how to interpret the values. I understand the concept of slip (at least i think so) but i dont know how to relate the values to real world.

indigo thicket
#

Very fresh unity user here. I'm trying to do a learning challenge making a ball fall and bounce and stuff. I've downloaded some pipes from the asset store which use mesh colliders. But my sphere does not fall through. The pipe objects have seemingly correct collision meshes

timid dove
#

if so, there will be no central hole in the collider

#

If the shape is convex it cannot have any internal gaps or holes

indigo thicket
#

All google-results said to enable "Convex" on the mesh collider, and without really understanding what that was i never tried to turn it off

timid dove
#

convex colliders are much more performant in general, but if your pipe is static (non moving) and there's not a million of them you should be fine

indigo thicket
#

Alright good to know, just doing a simple ball-bounce platform challenge as part of a learning pathway and wanted to try with something more than just basic platforms 🙂

past path
#

i use character controller as a player's collider

#

how can i keep player on ground when hits colliders?

#

player movement script
Vector2 move = new Vector2(Input.GetAxis("Horizontal"), 0); characterController.Move(move * Time.deltaTime * speed);

wide nebula
#

Start by first adjusting the step offset value on the CC component

past path
#

i tried to change slope limit but nothing changed

#

i tried 0, 15, 90, 180

#

oh sorry my bad 😅 i read step offset as slope limit. Now i change step offset value but still same :( when i try up to 1.50 character don't move

past path
#

Ok i found the problem. Capsule has rigidbody because it is an enemy and follows player. I enabled "is kinematic" option and boom

fathom coral
#

Is there a way to get a wheel collider that has a contact patch more similar to my actual wheel. I tried doing 2 wheel colliders near the edges of the wheel to get the effect from the rounded tire corners but the wheel does a ghost slide when at a stand still.

#

This is what it looks like with 1 wheel collider

supple pawn
#

Uhm, is it really needed?

supple pawn
# fathom coral

The only situation I could think of that you 100% need that is if you're doing some type of simulator

#

Otherwise hardcoding behavior should do just fine

fathom coral
#

Its for AI research

supple pawn
#

Then you probably want to steer off of unity's way of doing things

#

you can do multiple raycasts

#

Then get on dynamic friction, static friction, separate side to side friction from front and back

supple pawn
unique cave
#

Or just make your own volumetric wheel collider as this guy https://youtu.be/T8MB1Txi2-I (dont really, this guy has to be crazy at coding…)

lapis heron
#

Hello, I'm trying to more or less accurately simulate a Packaging Box used in the industry. It should fold to an almost flat position and extend to a cube shape. I have tried using Hinge Joints but with little success as the physics are very jiggly and don't work at all. I have tried using Inverse Kinematics as well but I'm struggling to make it collide with other objects to make it realistic. I'm quite new to Unity so if anyone has any idea of how this could be done it would be great. Thank you!

bleak umbra
lament stirrup
#

Hello, I would need help rigging my multi joint robot! What components you would use here to get IK like movement with joint constraints 🤔 I've been stuck on this problem for few days and I'm finally seeking help haha

lapis heron
lament stirrup
#

Couldn't find right tutorial for me anywhere

bleak umbra
lapis heron
#

I don't exactly need the perfect simulation but if it is able to interact with other objects then that's enough for me

hollow echo
lapis heron
#

However I haven't found anything similar online so I'm not sure how to proceed

#

If anyone has any recommendations I would be glad to hear them

bleak umbra
lapis heron
#

So, my project involves erecting the box from flat cardboard to its usual cubic shape, and to do so I need to test different mechanisms with Unity and check which is more likely to work once built physically

#

In practice this equals to simulating a hinge at the top of the flat cardboard holding it in place while a gripper sticks to one side of the box and rotates to erect it

#

Which means the box should be able to fold and open as well as have a collider so that the hinge can hold it in place

supple pawn
#

You can have two instances of the object, one open and one folded

#

Just simulate the transition, and when it's done switch the the one you need

#

Instead of holding it in place which can get buggy after a while

#

And make sure to increase the physics iterations

slow heath
#

Does anyone know if its possible to create a 'skin width' (like the character controller has) for a box or capsule collider?

timid dove
#

Skin Width on CC is related to how the Move method behaves

#

I think there's a "general" skin width setting for the whole physics engine. Project settings -> Physics -> Default Contact Offset

slow heath
#

I did manage to figure out that setting the default contact offset to like 0.00001 mostly fixed my issue, is that a 'safe' setting for it?

#

im making a box-shaped rigidbody character controller and it gets stuck between meshes even if the surfaces are completely flat

timid dove
#

I don't fully understand it but I have noted that there's all kinds of issues that a large setting has for it

timid dove
#

Look a thread that I participated in back in 2015 about the subject lol

slow heath
#

darn built-in physics is up to no good again

timid dove
#

reducing the default contact offset seems to be the simplest solution.

slow heath
#

ok ill go with that, thankyou!

slow heath
timid dove
#

so maybe?

slow heath
#

ok yeah that does the trick, while also not messing with every collider in the game as a bonus

#

oh wait no, now its sticking again, I guess ill just change the global parameter

devout gale
#

Suppose two footballs of the same mass are launched starting one meter off the ground, at 64 km/h, but one of them has fins.

When launched horizontally, the finned football would travel further than the normal football before touching the ground.

When launched vertically, they would rise and fall at the same rate.

It is not windy, and they are thrown with perfect accuracy.

How could I mimic the behaviour of the football with fins?

devout gale
#

Some people say that the one with fins would definitely fly further, and due to the fins it'll follow a much straighter line. For launching them vertically, the fins won't make a difference.

Other people say it wouldn't really unless you can't throw a spiral, in which case the non finned football loses speed much faster from drag while tumbling. It would also fly higher at a given velocity

inner thistle
#

Surely whichever is right, there's no difference whether you launch horizontally or vertically?

devout gale
#

You think so?

inner thistle
#

What could cause there to be a difference?

#

If the finned version flies further because it has less drag, it has less drag when thrown in any direction

#

Unless you launch them so hard they leave the atmosphere but 64 km/h isn't going to do that

pulsar cypress
#

Hi! I have a tricky problem 🙂 I have the following hierarchy: GameObject:Player(RigidBody) { Camera, GameObject:Sphere }
I'd like to always keep the "Sphere" GameObject in front of whatever direction the "Player" GameObject is moving (not necessarily where the camera is facing), facing the "Player" GameObject.
So far I've tried using Player.rigidbody.velocity's x,y,z values to position the "Sphere" GameObject, but that doesn't seem to work well, it's never ahead of the "Player" GameObject. I'm suspecting this is because velocity increases over time.
Any help would be much appreciated!

pulsar cypress
steep charm
#

Alright so I'm gonna try to word this. I have a characterController which rn is just a capsule collider. Using this online tutorial, I made it so the characterController will slide down slopes of a certain angle. However, it goes apeshit when running into completely vertical walls, or when a curved-edge of the capsule collider hits any type of corner or edge. Would anyone be willing to help me find a solution for this?

#

I can kind of tell WHY it's happening, but I can't necessarily figure out how to fix it

obsidian jacinth
#

Hi Guys. Looks this is a better place to post this question:

I was wondering if Unity had any built in way to allow a dynamic rigidbody to move up and down slopes without sliding off when stopping, or not bouncing off slope when moving down?

Or is that just a matter of buying an asset or doing some rather complicated code in C# to apply forces along the slope?

Basically is there anything similar Godot's snapping of one rigidbody to another with 'move_and_slide_with_snap?

wide nebula
#

There is no built-in in way, no, you have to do it yourself (or buy a character controller asset).

obsidian jacinth
#

Thanks man

nimble crater
#

Anyone knows where I can get free customizable physics for car?

granite vapor
#

I used AddForce as impulse for my player jump, but when stationary the force is barely strong enough to lift me off the ground and it looks like a stutter instead of a proper jump, why would that happen?

#

this is standing still

#

this is while moving

#

I feel like im missing an important thing about physics

desert wave
granite vapor
#

sure

#

Ill go grab it but iirc it's just an addforce

#

fired when the input system fires the spacebar event

#

I was thinking about implementing a separate force for stationary jumps but i'd rather not have hacky fixes 😭

granite vapor
#

Oh

#

for some reason that question made me figure out the problem

#

I think it's the custom friction code

#

Since im not moving it's overriding the velocity

#

now to think how to fix this i guess

#

🤔

desert wave
#

try using rb.velocity

#

and increase the y by your force

granite vapor
#

what if instead of setting the y velocity to zero i just take what i already have in that friction if

granite vapor
#

aye that didnt help

#

i thought you meant setting velocity instead of using addforce mb

#

Actually

#

it did

#

thank you

desert wave
#

np

muted tide
granite vapor
muted tide
granite vapor
#

Im trying to get a small horror game going

#

Based around using sounds to survive

muted tide
#

That sounds epic bro

muted tide
granite vapor
#

Not yet, theres barely a level

slow heath
#

does anyone know why my rigidbody controller is doing this?

#

the left ramp is a convex mesh, and the right ramp is not set to convex, ideally I want to make the level out of fewer probuilder objects which would require most stuf to not be set to convex

flat palm
#

Im removing a mesh collider and adding box colliders to an object. Is it bad for colliders to intersect?

meager sail
flat palm
#

For instance, is this bad?

tall sorrel
flat palm
#

@tall sorrel any particular reason to avoid it? I'm assuming it has something to do with not being able to detect which collider is responsible for a collision where the colliders intersersect?

tall sorrel
#

That would be one reason yes, it could mess up physics when using rigid bodies, it also could impact performance if you have a lot of colliders usually there might be a better way to combine the colliders, but its not entirely the worst thing in the world if you have colliders overlapping

flat palm
#

Okay thanks. I'm trying to figure out what's less resource intensive; A mesh collider or several box colliders as empty child object with primitive colliders attached? The reason for the child obiect instead of the parent object having colliders on it would he so you can use primitives, but angle them to the contour of the object, thus avoiding mesh colliders

shell adder
#

but usually multiple primitives will be faster

flat palm
#

Even if they are each their own object?

shell adder
flat palm
#

I watched that video durring some preliminary research. I suppose I just have to run some tests to determine the best performance for my use case

#

Thanks for your help guys I appreciate the advice and input : )

slow heath
#

looks like you should use mesh colliders for static scenery but anything that moves should use a bunch of primitives

#

and overlapping them is fine

granite vapor
#

@flat palm If you attach a rigidbody to the gameobject multiple colliders will act as a single composite collider, so unless mistaken it should count as a single collider and wont hurt too much

slow heath
#

posting a new video that might make it clearer if anyone can please help me fix concave mesh colliders shoving my player like this that would be awesome!

alpine grove
#

im new to ragdolls and just started using unitys built in ragdoll system, when i activate the ragdoll, it works but i thought possibly turning it off then back on would reset everything and make it ragdoll again but no, it stays in place from the first time it ragdolled, anybody know how to fix this?

midnight pagoda
#

I have an issue with 2D colliders that don't want to interact, someone could help me ?

devout gale
#
using UnityEngine;
                    
public class Bullet : MonoBehaviour
{
    public float Speed = 730f;
    public float Drag = 0.023875f;
    private Vector3 gravity = new Vector3(0,-9.81f,0);
    private Vector3 position;
    private Vector3 velocity;
    private float timeElapsed;
    private int layerMask;

    void Start() {    
        layerMask = 1 << 8;
        position = gameObject.transform.position;
        velocity = Speed * transform.forward;
    }
    
    void FixedUpdate()    {                
        velocity += gravity*timeElapsed; //apply gravity
        velocity += -Drag*velocity; //apply drag
        gameObject.transform.position += velocity * Time.deltaTime; //move the bullet in front of the ray
        RaycastHit hit;
        if (Physics.Linecast(position, position + velocity * Time.deltaTime, out hit, layerMask)) //interpret the result
            onLinecastHit(hit);
        position += velocity * Time.deltaTime; //move the ray forwards
        timeElapsed += Time.deltaTime; //increment time
    }    
    
    void onLinecastHit(RaycastHit hit)    {
            print("I hit" + hit.point.ToString("F3"));
            Destroy(gameObject);
    }
}

How's my bullet script? It casts a ray that's affected by speed, drag, and gravity.

timid dove
# devout gale ```cs using UnityEngine; public class Bullet : MonoBehaviou...

Seems mostly ok. Just a few things:

  • the position variable and the Transform position are redundant. You don't need both.
  • the timeElapsed variable is redundant. it can be replaced with Time.fixedDeltaTime
  • The position + velocity * Time.deltaTime calculation is being duplicated. You should just do it once and reuse the result.
  • hardcoding the layermask is a bit inflexible. Consider using a serialized LayerMask variable instead.
devout gale
# timid dove Seems mostly ok. Just a few things: - the `position` variable and the Transform ...

Here are the changes I made:

public LayerMask layerMask = -1;
void FixedUpdate() {
    velocity += gravity*Time.fixedDeltaTime; //apply gravity
    velocity += -Drag*velocity; //apply drag
    RaycastHit hit;
    Vector3 displacement = gameObject.transform.position + velocity * Time.deltaTime;
    if (Physics.Linecast(gameObject.transform.position, displacement, out hit, layerMask.value)) 
        onLinecastHit(hit); //interpret the result
    gameObject.transform.position += displacement; //move forward
}    
devout gale
#

Is there a reason why timeElapsed, the total amount of time that passed by, should be replaced with Time.fixedDeltaTime, a constant value?

#

The longer the bullet stays in the air, the harder it is being pulled towards the ground.

inner thistle
#

That's not how reality works

#

but if you want that kind of effect, go for it

devout gale
inner thistle
#

This doesn't have anything to do with terminal velocity

devout gale
#

what am I missing

inner thistle
#

If you multiply gravity by time elapsed, velocity increases exponentially

#

Pull of gravity is constant

#

The velocity of a falling object increases linearly

devout gale
#

oh that's true

timid dove
timid dove
#

that's why it's called fixed update

devout gale
#

I see

timid dove
#

it (effectively) gets called every 0.02 seconds and the logic within should represent what happens every 0.02 seconds

#

(this number can be changed in project settings)

devout gale
#

what I really need is the difference between the time the gameobject was instantiated and the current time

devout gale
#

i mean, i did before

timid dove
#

velocity += gravity*Time.fixedDeltaTime; this calculation seems correct to me

#

basically for the reasons Nitku said above

#

how's the behavior look now

#

if you want to use the full elapsed time since it started then you would be doing velocity = instead of velocity +=

timid dove
#

also try with drag = 0 for a minute

#

your current drag value is pretty aggressive

#

you're taking 5% of the velocity away 50 times per second

#

that's going to give you a very low terminal velocity

timid dove
devout gale
# timid dove show code
    public float Speed;
    public float Drag;
    Vector3 velocity;
    Vector3 gravity = new Vector3(0,-9.81f,0);

    void Start()    {
        velocity = transform.up * Speed;
    }

    // Update is called once per frame
    void FixedUpdate()    {
        velocity += gravity * Time.deltaTime;
        velocity += -Drag * velocity;
        gameObject.transform.position += velocity * Time.deltaTime;
    }
timid dove
#

yeah looks alright

devout gale
timid dove
#

experimentation?

#

Do you need drag?

devout gale
#

for large projectiles

timid dove
#

Well your drag model currently doesn't take the cross sectional size of the projectile into account at all

timid dove
#

Yes

devout gale
#
    public float Speed = 44f;
    public float SurfaceArea = 19f;
    public float DragCoefficient = 0.33f;
    public float AirDensity = 1.225f;
    private Vector3 dragForce;
    Vector3 velocity;
    Vector3 gravity = new Vector3(0,-9.81f,0);

    void Start()    {
        velocity = transform.up * Speed;
    }

    // Update is called once per frame
    void FixedUpdate()    {
        velocity += gravity * Time.deltaTime;
        dragForce = .5f * AirDensity * velocity * SurfaceArea * DragCoefficient;
        velocity += -dragForce;
        gameObject.transform.position += velocity * Time.deltaTime;
    }
timid dove
# devout gale

That message means your object is too far away from the origin for Unity to track its position properly

#

also dragForce should not be directly added to velocity

#

it should be multiplied by Time.deltaTime and divided by the object's mass

#

(as you do with any force to get the resulting velocity)

devout gale
# timid dove it should be multiplied by Time.deltaTime and divided by the object's mass
    public float Speed = 44f; //m/s
    public float SurfaceArea = 0.4185f; //m
    public float DragCoefficient = 0.31f;
    public float AirDensity = 1.225f; //kg/m
    public float Mass = 0.149f; //kg
    private Vector3 dragForce;
    Vector3 velocity;
    Vector3 gravity = new Vector3(0,-9.81f,0);

    void Start()    {
        velocity = transform.up * Speed;
    }

    // Update is called once per frame
    void FixedUpdate()    {
        velocity += gravity * Time.deltaTime;
        dragForce = .5f * AirDensity * velocity * SurfaceArea * DragCoefficient;
        velocity -= dragForce*Time.deltaTime/Mass;
        gameObject.transform.position += velocity * Time.deltaTime;
    }
#

looks good

#

this is probably what a baseball would look like if I ever threw one

wicked night
#

I don't know if this is the right place to ask, but how would I make something not register collision with the player, but detect collision with everything else as well as gravity?

haughty sparrow
#

Hey guys, I'm trying to get a Moving Platform working for my controller. I'm moving the kinematic platform by using MovePosition in FixedUpdate. On the player I'm settings the velocity to the velocity of the platform your standing on. (I get this through OnCollisionStay)

#

Moving Platform Code

#

Moving With Platform Player Code

#

The issue I'm having is that when I increase the speed a bit, the player very slowly slides off, and there is a small difference in velocity's between the player & platform rigid bodies. Any help appreciated 🙂

wicked night
#

In the Rigidbody

wicked night
#

Alright

#

Let me know if it works!

haughty sparrow
#

Wait i just realized, its the drag in general

timid dove
#

you should print that out and verify

haughty sparrow
#

rigidbody info

timid dove
#

that your player is moving at all is probably due to friction

timid dove
haughty sparrow
#

Alright so it was the drag on the player

#

last issue to fix is him walking slow on the platform

#

@wicked night

#

thx for the suggestion homie

wicked night
#

Yo

#

No problem

#

Did it work?

haughty sparrow
#

not exactly, but you reminded me that drag is a thing lmao, which was limiting the players speed

wicked night
#

Ahh

#

I see

haughty sparrow
#

🙂

desert abyss
#

Is OnTriggerEnter faster to compute than OnCollisionEnter? (2D, I can use either one just as well in my case.)

Intuitively I think so (because physics bouncing doesn't have to be calculated), but my intuition doesn't always work with Unity. 🙂

unique cave
#

Afaik oncollisionenter is much faster. Collisions are calculated once every physics update and if hit is detected, unity sends collisionenter message to scripts. Triggers on the other hand are not part of the physics loop. When you use them on script, the trigger collisions gets checked once per OnTriggerEnter function. So if you have 100 gameobject and everyone of those have OnTriggerEnter function on one of their scripts, trigger collisions needs to be calculated 100 times.

desert abyss
#

Gotcha, thanks. 🙂

wicked night
#

I don't know if this is the right place to ask, but how would I make something not register collision with the player, but detect collision with everything else as well as gravity?

lone bison
#

Hello everyone. My team are working on a university project where we try to implement a Billiard table/game. We got a lot done so far but we'r having a little problem for a while now and cant figure how to fix it. For some reason, after the billiard balls got hit by the cue, instead of slowing down in a fluently motion, they abruptly slow down. We are using the default unity physics and we'v been struggling with this problem for weeks now. We have found some unity forum messages about this and that it is supposed to be a unity bug, still I'm here and asking if someone found a way to fix this in any way. It would really help us a lot. thanks in advance.

lone bison
#

my bad. give me a second

lone bison
#

Here, the first example is right after the cue hit the ball. The second one occurs a second after the ball hit the wall.

#

Ignore the unrealistic mass and friction. We'r testing some values but the problem occurs either way. Just about the slow down for now.

lone bison
desert wave
#

as minimum and maximum

#

test them

lone bison
#

I remember. we already tried all options for the friction but non seem to help with the slow down

desert wave
unique cave
mortal crater
#

Hey - i wanted to make some kind of ragdoll here - so the arms will wiggle around while moving. Added a Rigidbody to the arm and a character joint but somehow it is messed up. Can somebody help?

lone bison
#

Thanks a lot @desert wave @unique cave ! We'll look into it 🙂

echo sluice
#

Do collision meshes take vertex normals into account?

#

I'd like to know whether I can skip proper vertex normal generation when generating collision meshes (for terrain).

unique cave
timid dove
unique cave
#

Yeah, thats how i understand it too

open skiff
#

A 2d rigidbody just slides after addforce. Any way to dampen the effect? I want it to slide a tiny bit, but increasing drag or friction makes the physics wonky

timid dove
open skiff
#

Friction, but that makes the physics wonky

timid dove
#

What I'm getting at is newton's first law of motion. Objects in motion stay in motion. If you want to slow something down you must apply a force in the opposite direction of motion

#

It doesn't have to be friction

#

You can apply any force you want whenever you want

echo sluice
open skiff
#

Maybe I could add force in the opposite direction for a frame after stopping

echo sluice
# open skiff I tried both

Using your own friction force correctly is not trivial - you can easily end up where applied friction force is too large and makes the object move in the opposite direction again.

rotund iris
#

why mu bulllet just slide on the wall

echo sluice
#

But Unity's collider friction shoulnt exhibit this

rotund iris
#

instead of destroy

open skiff
#

strange

echo sluice
#

Rigidbody drag is also a decent option. Just be sure to pick a low number (< 0.05 or something)

#

@open skiff Do you have top-down 2D or platforming 2D?

open skiff
#

Platforming

echo sluice
#

And it slides over platform when you want it to stop after a while?

#

Or is it gravity-less

open skiff
#

I'm making a game like Terraria or Starbound, so sandbox, and it just slides

#

Like a terribly designed ice level

echo sluice
#

right

#

collider friction man

#

i cant imagine you cant get the desired result with that

open skiff
#

Let me try again

echo sluice
#

Also, there are different friction modes. Something like multiply, average, min, max, right?

open skiff
#

think so

echo sluice
#

Try to stick to the default (multiply or average probably)

open skiff
#

reasonable, thanks!

echo sluice
#

and start with friction like 0.5 and tweak from there

#

Although I dont think friction > 1.0 is a thing.

open skiff
#

yeah

echo sluice
#

Keep in mind that both the platform collider and the rigidbody collider have their own PhysicsMaterial (although this is kind of obvious when you think about it).

#

If you disabled rotation on the Rigidbody then you probably need even lower friction (< 0.2)

open skiff
#

Yeah

#

is Unity's mass in kgs?

echo sluice
#

There is also a project-default PhysicsMaterial in settings somewhere i believe.

echo sluice
open skiff
#

nice, I'll set the player to the appropriate weight in kgs

echo sluice
open skiff
#

Yeah

#

2 meters tall

echo sluice
#

👌

open skiff
#

around 80kgs for someone (took average between lowest of both genders)

echo sluice
#

Thats fair

#

I'll be away for 30 min. Let me know if you run into issues.

open skiff
#

k, thanks!

cobalt pilot
#

why does increasing the number by which I set my WheelCollider's MotorTorque not increase the speed?

#

the rigidbody drag is set 0

echo sluice
#

@cobalt pilot You mean its not spinning at all?

cobalt pilot
#

it was but it wasn't getting faster as I was increasing the torque

#

found a sweeetspot at 1000

#

but not using wheeelcollider anymore now

icy nexus
#

Hello, I want to make it so that my character doesn't glitch into the wall and I have a feeling that this problem has something to do with physics

#

I added a rigidbody and a platform effector so far

stuck bay
#

Hello, We have turned Physics off in our game. Yet I would like to reproduce the "AddForce" algorithm. Does anyone know if there is an implemention anywhere for me to study?

#

Would this be a good start?

#
Toptal Engineering Blog

Today's video games offer an incredibly realistic, immersive experience, due in large part to their true-to-life simulations of physical phenomena. By far the most commonly simulated effects are those of Rigid Body Dynamics.

Toptal is pleased to have our very own Nilson Souto present this first installment of our...

#

it actually is

#

This too

echo sluice
stuck bay
#

That's a great question and, I'm doubting my design choice as well. I want to optimize my code and only kind of need this portion of physics. PhysX is taking up a huge portion of the performance. So, in the concept phase we are doing some tests of running the code with and without PhysX. By doing our own implementation I could also tweak how often I do the calculation; furthering our performance.

#

But, please, put me to the hot irons and question me

lapis plaza
#

you can slim your physics scene too

echo sluice
lapis plaza
#

if you only need AddForce, you can remove all extra colliders and don't have your rigidbodies collide with anything

#

but without knowing further details it's really hard to tell why the physics were heavy to begin with

#

general assumption is.... you can't make physx equivalent yourself and have it perform better unless you strip out all the expensive to compute parts

#

(meaning it will be way less functional)

stuck bay
echo sluice
stuck bay
echo sluice
#

Im not even sure if the last one (moving non-convext MeshColliders) is still allowed in Unity

lapis plaza
#

it is not

stuck bay
#

this is the proof of concept video

lapis plaza
#

they removed that possibility in Unity 5

stuck bay
#

we are supposed to have 100s of units per side

echo sluice
#

Heck I'd use CapsuleColliders for all of those.

#

What kind of colliders do they have right now?

stuck bay
#

I believe MeshColliders Don't remember if they are convex or not. We've started with a new code base

echo sluice
#

IF the performance problems are indeed MeshCollider-related

#

You ought to just check it out and try it if that was indeed the case

stuck bay
#

You've proven a great point of doubt I've had and will switch coarse

#

Thank you!

#

Ohh, there is one thing though... It's going to run on an Oculus/Meta Quest 2

echo sluice
stuck bay
#

no they run without a PC connected to it. It's basically a Cell Phone level processor

echo sluice
#

Oh

stuck bay
#

This is what I did with DOTS

echo sluice
#

Well if you would like to get an idea of what physics performance is like on that thing you could perhaps spawn 1000 basic shape colliders and let them bounce around in a box or something. Just as a quick check to see if that will kill the CPU or not

#

If you're already comfortable with DOTS - there's always DOTS physics

#

itll do everything for you

#

forces, collisions, etc

stuck bay
stuck bay
echo sluice
#

Only thing it cant do from what ive experienced myself is have 2 colliders that move within the same rigidbody (imagine something like a retractable panel on a vehicle or whatever)

stuck bay
echo sluice
#

But depending on the fidelity of physics you need, doing it yourself can be a real headache.

#

If you dont know or care about rotation inertia tensors then perhaps you could get away with writing simple AddForce(...) and AddTorque(...) and such yourself.

#

AddForceAtPosition() is also not too difficult

stuck bay
#

Another debate has to occur over "Rigid Bodies" collisions without Physx. To keep the ships from colliding together.
The question is can you turn off Physics and still have rigid bodies so that two gameobjects don't collide?

echo sluice
#

But as soon as you need something more advanced (joints, proper collision physics, friction) you're probably better off trying to optimize your PhysX usage as much as possible.

echo sluice
stuck bay
#

Actually turn off PhysX. There is a line of code to do that : "Physics.autoSimulation = false;"

echo sluice
#

Oh, im not familiar with that

#

So rigidbodies will stop moving then?

stuck bay
echo sluice
#

Ok im not sure if im understanding your question but you want to know if rigidbodies can still "maintain separation from another through the collision system" while the actual simulation is frozen?

stuck bay
#

Yes, I'm not going to test it this week but that's on the docket

echo sluice
#

Man, I really wouldnt know. This sure is a strange way to use physics in unity

stuck bay
#

I know, it's squezing performance out for a Meta Quest

echo sluice
#

My advice remains unchanged lol: really try to see how much performance you can squeeze out of PhysX.

#

Oh that thing has a modern snapdragon processor

stuck bay
stuck bay
echo sluice
#

Phone processors are kind of funny in a way because theyre really unreasonably fast at certain things. E.g. video encoding

stuck bay
#

If I can get them "maintain separation from another through the collision system while the actual simulation is frozen" and write my own simple "AddForce" then as far as I can see we are set

#

I'll still going to try it out with PhysX on as well. No need to complicate the code, if it does work out

#

Also if PhysX works my programmer will go nuts with collision based damage when I've already planned out that our damage will be a math based calculation

#

We've be going back and forth on that debate of how to handle damage

#

That would add a bunch more phsics related stuff to an already taxed system

echo sluice
#

I had AddForce for particles somewhere but I cant find it, so I'll do this from memory:

  • For VelocityChange: velocity += inputVector;
  • For Acceleration: velocity += inputVector * deltaTime;
  • For Impulse: velocity += inputVector / mass;
  • For Force: velocity += inputVector / mass * deltaTime;
stuck bay
#

Now I'm thinking, we go down the road of leaving PhysX on during our preproduction phase and if it doesn't work out we do it my originally planned way

echo sluice
stuck bay
#

The first link I posted

echo sluice
#

Right. Its just physics basics.

#

AddTorque is a bit more complex

#

AddForceAtPoint is more or less a combination of AddForce and AddTorque

stuck bay
#

I'm not going to need AddTorque. We just need the part you stated

echo sluice
icy nexus
#

Hello, I am trying to make a platformer game. But I have a slight problem with the image above happening. I think it has something to do with physics so yea

icy nexus
desert wave
icy nexus
#

yes

desert wave
#

that's the problem, you need to use a physics friendly way

icy nexus
#

ah

#

so what I am thinking now is that with that platform object I create a wall and check the trigger or smth

desert wave
stuck bay
#

@echo sluice Thank you for the debate

echo sluice
#

@icy nexus Instead of modifying transform.position and transform.rotation, try modifying rigidbody.position and rigidbody.rotation. Doing it like this should take collisions into account from what I remember. (Otherwise, you can also try to use actual forces)

echo sluice
echo sluice
#

@icy nexus Oh I think i made a mistake. It should be rigidbody.MovePosition(...) and rigidbody.MoveRotation(...).

icy nexus
#

ah I think you are right cuz im getting an error but its fine

echo sluice
#

So for rigidbody.MovePosition(...), you input the new position it should be

#

Also your character should have a Rigidbody2D if it doesnt already have one

icy nexus
#

I should also put this in fixedupdate not update right

#

cuz it is lagging

echo sluice
#

Although FixedUpdate does weird things with input

icy nexus
#

oh

echo sluice
#

You can store input data in Update() and use them later in FixedUpdate()

#

But does it collide properly now?

icy nexus
#

yes it does work

#

but I think I see what you mean about weird things with input

#

the up arrow input lags pretty hard

echo sluice
#

Let me know if you need help with working around the input problem

icy nexus
#

ok

#

@echo sluice I am still having problems with the code and I think its because it only reads one input at a time

#

plus for some reason the downward velocity is very weird

#

I think I know how to fix that tho

#

actually im not sure

echo sluice
#

@icy nexus I have to go now but you can send me a screenshot of your code in a message to me if you want

#

then its easier for me to find what is going on

icy nexus
#

ok

frank shore
#

how to add jumping to rigidbody??

tender gulch
#

Does anyone know how to describe the next situation scientifically? How do you call the force that prevents the bottom part of the "pole" from going up? Friction? How would you calculate it? I want the bottom part to remain static on the same spot instead of sliding when the object falls to the side.

timid dove
#

friction force comes from the coefficient of friction between the two surfaces * the area of the contact patch * the force pushing the two objects together

#

so - bigger contact patch = more friction. Objects being pushed together harder = more friction

tender gulch
#

Would the force that push it together would be gravity in this case?

timid dove
#

yes

#

maybe

#

unless something else is also pushing the pole down

tender gulch
#

And do I need to get a project of it along the object vertical axis?

timid dove
#

yes, you need the downward component of it only

#

any sideways component doesn't contribute to the friction calculation

#

or more precisely:

  • parallel force doesn't contribute
  • orthogonal force contributes
tender gulch
#

So it should be something like frictionCoefficient * Dot(gravity, objectDown) * gravity?🤔

#

How do you even call a motion of a an object falling on it's side while supported by the ground? Is there a term for that? 😅

#

"toppling"?

echo sluice
tender gulch
echo sluice
#

Oh lol I completely interpreted your explaination the other way around

#

red cross on arrow pointing up = "this force is missing - i need it!"

#

Yea nevermind, the other one is friction as you and the other person said

candid hull
#

Hi !
I just want to confirm : Does we need to use the fixedDeltaTime when using an AddForce / AddForceAtPosition ? (if used in a FixedUpdate of course)
I'm working on an airplane simulation, and i was struggling with the calculation of aerodynamic forces (and many other things) where i always had to add a x50 multiplier to have a "realistic" result... And i just realised that this should be the reason X)

timid dove
lapis plaza
#

also as a side note, you shouldn't even use AddForce outside FixedUpdate

#

well, I now mean if you use force mode, it's fine for impulses regardless where you call it from

candid hull
lapis plaza
#

it's physics though...

#

(newton's second law)

candid hull
#

i'm talking about the AddForce that already does the multiplication with the delta Time, not the physics ^^

timid dove
#

so it is intuitive that forces are meant to be applied over time and that they work in standard units. the unit of force is a newton.

lapis plaza
#

Force by definition includes deltatime, if you somehow take it away for game physics that's actually very counterintuitive

candid hull
#

yup i see what you mean. 👍

lapis plaza
#

you can always just use ForceMode.Impulse instead of ForceMode.Force (which is the default) if you want to omit the deltatime part

#

but then you have to add the DT component to it if you want actual forces so you are just doing what physics engine did for you in the first place 🙂

pliant fern
#

Theres something i have a problem with but im not sure how to explain it, its a little complicated, i tried explaining it before but no one could really understand. im trying to make a water slide but the tube won't curve with the slide

#

basically what i'm doing is i have the tube attached to an invisible sphere

#

to ensure that the tube doesnt suddenly stop midway and keeps going

#

but its rotation is also frozen so it doesnt roll with the ball

#

but that also makes it so it doesnt really look like its properly sliding down

pliant fern
#

so that it doesnt rotate with the sphere

#

because then it would be rolling and that would look wrong

upper owl
#

hey, i have a physics questions about objects with front/back heavy masses
suppose i have an object like a ninja throwing dagger, where the front part is the heavier metal blade and the back part is the lighter grip
in real life when throwing this dagger it would obviously fall blade-first into the ground every time (assuming it has the time to rotate before hitting the ground)
is there any way i can simulate this on game objects? or atleast a clever way to fake this kind of effect?

unique cave
upper owl
#

really? how?

unique cave
#

rb.centerOfMass

upper owl
#

wut

#

you're telling me there's just a center of mass property

unique cave
#

yes? just change it to whatever you want

upper owl
#

dang, and here i was preparing my heart for a whole headache of physics coding
i'll check out the docs, thanks a lot

unique cave
#

you can change the center of mass to closer to the blade and it should make the trick

upper owl
#

yea im looking into it now
shame i cant do it in editor

unique cave
#

you could probably make some sort of editor script to change it

upper owl
#

probably, but i dont think i'll get into that this early into development

upper owl
#

well, the center of mass is working when the object is balancing like a seesaw, but it doesnt make changes to the rotation when falling down to make the heavier side land first

unique cave
#

air resistance is also very negligible so it doesn't make much sense to go heavier side first. anyways im pretty sure there's no build-in way to do that, you need to code that yourself (maybe you could use either AddForceAtPosition or AddTorque)

#

id try to add force that's pointing at opposite direction of velocity at the lighter part of the object (using AddForceAtPosition). that would simulate air resistance on the lighter part of the object and would rotate it to go heavier part first. if you move the center of mass closer to the heavier part, even small air resistance should be able to rotate the object without slowing down the object too much

upper owl
#

if i were to throw a knife in the air, the heavier blade side would always be the one pointing down when it falls, right?
isnt that because it's heavier compared to the lighter side of the handle?

unique cave
#

in real life you need to be very talented at throwing them if you want them to go blade first. in this video he actually uses knifes where the handle side is heavier, it doesn't matter https://youtu.be/xuSjZ9mWIHU?t=530

upper owl
#

hmmm, i'll have to reconsider my approach then

unique cave
#

games doesn't need to be physically accurate but that's the reason why it doesn't work like that by default

upper owl
#

i think i'll just fake it by setting some other pivot point for rotation

#

and just do it manually with a gradual pointing down rotation

unique cave
upper owl
#

ill give a try

sudden flame
#

Hi. How do I make a mesh collider work? Like, I've exported a hall from blender to Unity, but the mesh collider doesn't seem to work properly, the physics inside the hall just do not work

unique cave
#

Is the mesh collider set to convex?

sudden flame
#

Yes

timid dove
#

well... convex things can't have an "inside" of course

#

it's convex

sudden flame
#

then how do I make it so it has an "inside"?

timid dove
#

don't make it convex

sudden flame
#

But will it work then?

timid dove
#

why wouldn't it?

sudden flame
#

I don't know. All the times I tried without convex it just didn't work as a collider I don't know why

timid dove
#

Well I can't speak to that.

#

But if you have a cursory understanding of "convex" you would know that it wouldn't work the way you want if it's convex

sudden flame
#

Well, I'll try disabling "convex"

#

Nope, it just doesn't collide at all

#

The capsule just falls through it like nothing

#

That's why I do not understand what disabling the convex option would do

timid dove
#

if it has a dynamic body, then concave colliders are not supported

#

Concave vs convex is this. Convex has no "internal space'. Any two points on it can be connected by a line that never exits the shape

timid dove
timid dove
#

then your geometry is just messed up

#

honestly it's better to make colliders for something like a hallway out of primitives anyway. It'll be more performant

sudden flame
#

well okay

#

I'll try that thanks

#

And is there any way to make a box collider but like inverted?

#

that I can be inside it?

timid dove
#

4 walls, a floor and a ceiling

unique cave
#

I guess mesh collider with inverted normals could work

sudden flame
#

Is there any way to do that in Unity?

unique cave
#

You just need to make the mesh in blender or other modelling software

sudden flame
#

Oh but like with inverted faces?

#

so everything is like pointing inside?

unique cave
#

Yes

#

You can recalculate normals inside for example

twilit axle
#

https://www.youtube.com/watch?v=Qjf6_tu_Oq4
Hi guys how would you recommend beginning to do something like this? (Breaking water, Controlling water movement)

Today I'm super excited to be showcasing Breakwaters. In Breakwaters, you explore a procedural world with dangerous ocean depths and massive Titans in an Exploration Survival game that changes the way you interact with water. Displace water with powerful crystals harvested from the world, delve into its depths to collect rare resources, build wa...

▶ Play video
snow sky
timid dove
#

Also there's no need to repeatedly call IgnoreCollision every frame. Doing it once in Start is sufficient.

snow sky
#

gear is moving guy to the left

timid dove
#

you don't need any code for that

snow sky
#

A.because there will be several of them and they should be separated from each other
B.they are in different layers

timid dove
#

That's all you need to do

#

no code is needed (make sure you do it in the 2D physics section, not normal 3d physics)

snow sky
#

thank you 🙂

compact hedge
#

Should I be putting "wheel" colliders on the wheels of the mesh (which are children of the root part), or should I add "wheel" colliders to the root part of the mesh and just move them to where the wheels are?
Or does that not affect the wheel physics at all?

lethal owl
#

ive got an object with a rigidbody whos colliders are in the childrens object, this to make it more modular, however, when i add a force to the parent it also makes the child colliders rotate a bit (in local space), how can i stop this, they need to act like one rigid whole?

#

also if i add a force to an object in a vacuum that isnt in line with the CoM, will the object still get inertia?

jovial wraith
jovial wraith
# lethal owl also if i add a force to an object in a vacuum that isnt in line with the CoM, w...

When you apply a force that is not in line with an object's center of mass, it has two effects--it has a "force-like" effect that gives the object a linear acceleration, and a "torque-like" effect that gives the object rotational acceleration. If you split the force into part that is pointing toward the CoM and part that is perpendicular to that first part, the part pointing to the CoM acts as a force and the part perpendicular acts as a torque.

sage wolf
#

Hey, i figured this is the Channel to ask Collider Questions, if not please point me there

#

I need to find the closest point on the surface of a collider, but using collider.ClosestPoint gives me point inside the collider as well, i need it ONLY on the surface so i can push points outside of the collider

#

Does unity have a function for that or do i need to figure it out myself ?

bleak umbra
lethal owl
#

they dont have a rigidbody, only the parent object has it

patent fractal
#

bit random - im working on a hooded cape for my character, using the cloth component. I want to make it so that I can fold the hood back and put it over at will. Any ideas?

arctic marsh
patent fractal
arctic marsh
patent fractal
#

I was just wondering if there was a simpler way

arctic marsh
patent fractal
river pivot
#

how can I move the player behind the tree? I tried changing the sorting layer and layer order but it just makes it worst

shell adder
wide nebula
#

You need to fix your sorting layers too. If you made them all on various layers to attempt to fix it to begin with.

flat palm
#

If I am using a character with rootmotion and using a walk animation blend tree to blend between each cardinal direction with WASD input, should I have the animation controller update mode in animate physics or normal?

#

It is a non rigidbody character. It's just using a character controller

uneven bone
#

Im making a soccer game, but instead of pushing the ball, my character just walks on top of it, how do I fix this?

wide nebula
#

Are you using the character controller?

uneven bone
#

yes

wide nebula
#

Play around with the values, such as lowering the step offset.

#

But also note that the CC doesn't interact with rigidbody physics, if you're expecting your ball to be pushed around by it.

#

You have to do your own detection (there's a collider detection built into the CC), and apply your own forces to the ball.

uneven bone
steady tartan
#

why Rigidbody2D don't have AddExplosionForce ??
it's really Unfair 😦

marble blade
#

What can cause inconsistent physics between a HDRP and a URP version of the same project?

I have a VR game made in HDRP and I also release it in a URP version to ship on Quest standalone. The code base, prefabs, physics (solver iterations...) and time (fixed timestep...) settings are exactly the same and the rigidbodies and joints have the same parameters at runtime. Yet, I can notice that the joints are less stiff in the URP project!

The FPS is approximately the same. This happen in both editor and builds. The main noticeable difference between the two versions is that the HDRP project uses OpenVR, while the URP project uses OpenXR on desktop, and Oculus on Android (the issue is visible in both desktop editor and android build) .

Do you know what can explain the difference of stiffness?

marble blade
devout gale
#
using UnityEngine;

public class HorizontalLaunch : MonoBehaviour //zero gravity
{
    public float Speed = 10f; //m/s
    public float DragCoefficient = 0.4f;
    public float SurfaceArea = 0.79f; //m
    public float Mass = 2f; //kg
    private float airDensity = 1.225f;
    private Vector3 velocity;
    

    void Start()    {
        // initial velocity v0
        velocity = Speed * transform.right; 
        Debug.Log(calculateTimeToReach(3f, velocity));
    }

    void FixedUpdate()    {
            //change velocity over time
            var dragForce =  velocity * 0.5f * airDensity * SurfaceArea * DragCoefficient;
            velocity -= dragForce * Time.deltaTime / Mass;
            var displacement = velocity * Time.deltaTime
            //move object
            gameObject.transform.position += displacement;
    }

    float calculateTimeToReach(float x, Vector3 v0) {
        return (float) 
          System.Math.Sqrt( 
            (Mass*x + Mass*v0.magnitude) / 
            (0.5f * v0.magnitude * airDensity * v0.magnitude * SurfaceArea * DragCoefficient)
          );
    }
} 

I am trying to write a method that can calculate the time to reach a given position before the projectile is launched. calculateTimeToReach(float x)

#

I do this by rewriting the function used to move the object.
https://imgur.com/LqTKivR

var dragForce =  velocity * 0.5f * airDensity * SurfaceArea * DragCoefficient;
velocity -= dragForce * Time.deltaTime / Mass;
var displacement = velocity * Time.deltaTime
Fd = v * 0.5 * p * A * Cd
v = v - (Fd) * t / M //insert dF
dx = v * t
v = v - (v * 0.5 * p * A * Cd) * t / M
dx = (v) * t //insert v
//the result
dx = (v - (v * 0.5 * p * A * Cd) * t / M) * t
dx = v - (0.5 * v * p * A * Cd * t^2)/M //simplify
#

Then I solve for t:

t = ±√((M * dx + M * v0) / (0.5 * p * v0 * A * Cd))
lyric timber
#

Hey everyone. Simple question here. PhysicMaterial (sic...) has an enum for determining which friction combine method is used when determining the (dynamic or static) friction coefficient for a collision between two objects.

#

The documentation says that, when these two enum values are not the same, the one with the highest priority is chosen. "The priority order is as follows: Average < Minimum < Multiply < Maximum." (quoting unity documentation)

#

However, when casting the PhysicMaterialCombine enum to int, the order goes 0 = Average, 1 = Multiply, 2 = Minimum, 3 = Maximum

#

My suspicion would be that the documentation is wrong here, flipping Multiply and Minimum. That would mean the physics internally just take the highest value.

#

Or is it actually worse and is the documentation correct, with the physics blithely ignore the enum ordering?

timid dove
lyric timber
#

Yeah, well that's sort of the issue. I don't think I have any reliable way of "requesting" the final results, so my best bet would be create a couple of wildly varying PhysicMaterials and try and estimate what combination of values best matches the observed behavior.

#

Doable, but I was hoping somebody might just have run into this before, before I had to do that work 😉

nimble crater
#

anyone familiar with wheel colliders? i wanted my car to be able to go up the curb smoothly but it's very sudden

lapis plaza
#

wheel collider is just one ray down from the center

#

so if you want that kind of case to look smoother, your curb collider has to be more round

#

@nimble crater

#

or rather, smoother

lyric timber
#

7th column shows Multiply takes precedence over Minimum.

queen inlet
#

HingeJoint. I find the documentation for what resting angle is relative to confusing (or non-existant).
I've come to the conclusion the actual direction is the (joint.anchor - transform.position). I kind of expected it to be (joint.anchor - joint.connectedAnchor). Anyone have any insight regarding this?

stuck bay
#

Is there an alternative for APR Player

jovial wraith
lyric timber
stuck bay
#

To make it simple, I'm trying to implement an animation when my character is in the void (that's not the problem): it's gravity that's not acting correctly. I want him to fall faster, if possible:

timid dove
#

and is thus overwritign the Rigidbody's attempts to fall due to gravity

#

Do you actually need Rigidbody physics for your game? Maybe just do the gravity bit yourself.

stuck bay
#

yes I need it

snow surge
marble blade
#

I need to attach a payload at the end of a robotic arm driven by articulation bodies.

Having a classic rigidbody on the payload, with a fixed joint won't do, because the joint must be very stiff.

I tried to parent the payload under the arm end using a fixed articulation body but this causes the whole articulation body architecture to reset in its initial pose.

What' is the best practice?

hidden ice
#

So I have a basic model of a crate, should I make it into a mesh collider for more accurate particle effects or keep it as a box collider for better preformance?

unique cave
hidden ice
#

ah

unique cave
#

box collider is heck a lot of better in terms of performance

hidden ice
#

makes sense

storm fable
#

I made this char in vroid and wanted to use it in vrc but the hair keeps doing that, it has no weight it gets just stuck in the air, dont know if i have to do something different in vroid, blender or unity

storm fable
#

here is the same problem in vrc with the test before

charred torrent
#

im using hinge joints on something for vrc but i keep getting clipping issues and when theyre moved they fly away from where theyre connected to

hidden ice
#

So I have a shipping container object that I want the player to be able to go through, but still collide with the walls. I know mesh colliders are expensive, is there an alternate solution?

unique cave
hidden ice
#

Ah

granite vapor
unique cave
granite vapor
#

Yeah my bad, meant to say static

unique cave
#

It doesnt need to be static either

#

By static I meant you dont change the shape of collider runtime which is quite expensive

granite vapor
#

Oh even better. Thanks for the info

#

I'm going ask something else in here in the meantime. I have a set of points which make out a path. An object follows this path. I thought

time to move from point to next = distance between the two points / a constant
would be enough to have smooth movement between points but for shorter distances it still goes faster than with longer distances, what am I failing to consider in my calculation?

unique cave
#

Lets say you have only 1 active rigidbody in the scene and 1000 objects with mesh colliders on it, only very few of closest of those mesh colliders needs to be checked because bounds doesnt collide. For those 995 colliders, type of collider doesnt matter at all because they are ignored anyways

granite vapor
split wedge
#

Is there a way to physically move a car by rotating the tires?

#

I'm currently trying hinge joints, but if the tires rotate, the temporary car model box slowly approaches the ground

unique cave
#

I remember seen some rigidbody + joint tutorial on youtube but ig thats not going to be very good since theres no any good collider shapes to match the tyres

split wedge
#

Mesh?

#

Mesh collider with convex is my current use

unique cave
unique cave
split wedge
#

Wheel Collider has shot my car to the moon when it hits an obstacle a tenth of a unit high before

#

I don't know what's with it

#

I've also tried a raycast based car system, but when I turn, the car banks (I think that's the right term) way too much on it's turns

upbeat scroll
#

Is PhysX 4.1 the latest PhysX version integrated from Unity 2019.3 on?

shrewd umbra
kind light
#

Anyone who could help with Ragdoll Physics? My characters head is going all over the place.

kind light
#

Its most likely something to do with the wrong relations between joints ( beginner guess though )

#

But would really appreciate if someone can explain on what I should check when I get this kind of behavior.

#

Physics Debug

jovial wraith
# kind light Physics Debug

it looks like you have some overlapping colliders in the hips area. Go through and make sure none of your colliders overlap. That's my guess as to what's causing the jitter. The Brackey's video on setting up ragdolls is pretty good. It shows how to do a lot of the configuration. Following all the steps there will probably help debugging your issue as well.

kind light
jovial wraith
# kind light So the colliders must not touch each other by any means?

They can't be inside each other. If they are, the physics system will try to push them out (this is what dynamic rigidbody/colliders do), while simultaneously trying to keep them in their original position (this is what joints do). It wants them to be in two different places, so it ends up very unstable (causing jitter).

kind light
#

Thanks for the great explanation man! So I can freely use some extra space to separate them from each other and possibly avoid jitter.

#

Also the ragdoll maker-unity tool didn't make some parts so I had to create them on my own

north hollow
#

When Unity says Vertex data for meshes isn't in the Dedicated Server builds, does that mean they expect that collision and physics queries won't work against any non-read/write asset?

#

It seems difficult to make performant client and server shared assets if the server requires all collision meshes to be read/write

lapis plaza
#

"and not used for internal systems" is probably the key line here, whatever they mean by it

#

I'd just test it in practice instead of making assumption that everything has to have read/write checked. I mean doesn't Unity bake collision data for physics separately anyway?

#

having actual mesh data in server side that doesn't have to render anything makes very little sense, which is probably the main reason for that optimization

#

@north hollow ^

#

having read/write tagged textures and meshes on server builds is also probably related to just keeping the thing from breaking as you'd typically want to manipulate that data if you have those options checked.

eager herald
#

In this scene, there are elongated rectangles that represent lines. The player can drag them to rotate and lengthen them in order to accomplish the winning scenario. I need a way to get - when two of these game objects overlap - get the exact point and notify the player.

I tried to add a Collider2D to each game object, and then a Rigidbody2D with x,y coords fixed. Then using an OnCollisionStay2D method I got the ContactPoint2D and sure enough the first contact point from contacts[0].point. The outcome though was not what I expected, with said point sometimes not being even on the surface of at least one of the colliding game objects.

Any suggestions to how I could fix this, or another way to implement it would be welcome.

north hollow
#

Actually, me asking this question is because I just upgraded our game to Unity 2021.2.4 and we started falling through colliders when playing our game against our dedicated server backend. I have created a very simple repro case and sent that in as a bug. In this case I don't think the game objects are tagged as static in our game level since they are only enabled in certain game modes. Some of the colliders do still work on the headless server though.

#

I should update my bug reproducing project to test for the case where a non read/write mesh is marked as static to see if it gets collision on headless server.

north hollow
#

For anyone curious, my tests show that a collider marked as static but not imported as a read/write mesh does not work in the headless server physics

lapis plaza
#

huh

#

there isn't any toggle for that either?

north hollow
#

I can't find any configuration that seems to control what is stripped out of the Dedicated Server builds

flat palm
#

When I log a normalized WASD movement vector and am holding A and W I see that it outputs (-0.7, 0.7). My understanding is that normalization ensures the value is 1 regardless if the input vector is < 1 or > 1. So if I'm understanding this correctly, the output is correct because it is adding sqrt(0.7^2 + 0.7^2) which would be ~ 0.98 or pretty close to 1

mighty sluice
#

Is there anything equivalent to the interpolate function for rigidbodies that applies to classic Particle Systems?

wary sedge
#

I am trying to set limbs modularly, where some limbs may have ‘sockets’ where other limbs can set - however i just need to them to freely flop around. I am using Configurable Joint, and everything either balls up or will fly around like crazy. Limbs are being instantiated via script.

it is supposed to be more chain-like, not ball-like.

wary sedge
#

The green is player, blue is a body-like limb (has sockets that limbs can connect to, setup with sockets as the location that limbs are set to w/ autoconfigure anchor) and the purple is limbs.

timid dove
#

probably not setting the anchors correctly, so they're all anchored to one spot in the middle somewhere

wind meadow
#

dunno if this goes here but i want to try and create a sort of parallelogram collider with an object like this. Is there a way to do so in 2D?

wind meadow
#

follow up, is it significantly resource intensive?

#

nvm i sure it's more than box but not enough to turn my Laptop into a nuke

teal ore
#

i am trying to make a car but the car isn't moving

#

as you can see the wheels are rotating but the car isnt moving

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CarController : MonoBehaviour
{
    public void GetInput()
    {
        m_horizontalInput = Input.GetAxis("Horizontal");
        m_verticalInput = Input.GetAxis("Vertical");
    }

    private void Steer()
    {
        m_steeringAngle = maxSteerAngle * m_horizontalInput;
        frontDriverW.steerAngle = m_steeringAngle;
        frontPassengerW.steerAngle = m_steeringAngle;
    }

    private void Accelerate()
    {
        frontDriverW.motorTorque = m_verticalInput * motorForce;
        frontPassengerW.motorTorque = m_verticalInput * motorForce;
    }

    private void UpdateWheelPoses()
    {
        UpdateWheelPose(frontDriverW, frontDriverT);
        UpdateWheelPose(frontPassengerW, frontPassengerT);
        UpdateWheelPose(rearDriverW, rearDriverT);
        UpdateWheelPose(rearPassengerW, rearPassengerT);
    }

    private void UpdateWheelPose(WheelCollider _collider, Transform _transform)
    {
        Vector3 _pos = _transform.position;
        Quaternion _quat = _transform.rotation;

        _collider.GetWorldPose(out _pos, out _quat);

        _transform.position = _pos;
        _transform.rotation = _quat;
    }

    private void FixedUpdate()
    {
        GetInput();
        Steer();
        Accelerate();
        UpdateWheelPoses();
    }

    public float m_horizontalInput;
    public float m_verticalInput;
    public float m_steeringAngle;

    public WheelCollider frontDriverW, frontPassengerW;
    public WheelCollider rearDriverW, rearPassengerW;
    public Transform frontDriverT, frontPassengerT;
    public Transform rearDriverT, rearPassengerT;
    public float maxSteerAngle = 30;
    public float motorForce = 50;
}