#⚛️┃physics

1 messages · Page 83 of 1

unique cave
#

Isn't the error message very self-explanatory? non-convex + non-kinematic is not an option anymore. non-kinematic rigidbodies can only be done using convex mesh colliders and primitive colliders

#

you can make the collider out of multiple colliders (compound collider)

civic field
#

why would small colliders have issues ??

#

they are not even absurdly small

neat coral
#

Your object is in the range of centimeters

#

Box2d isade to work in yhe the range of meters

civic field
#

I put it at a normal sccale

#

and there is still a gap

prime rain
#
public Vector3 getTorqueNeededForAcceleration(Vector3 acceleration)
    {
        Vector3 tensor = myRB.inertiaTensor;
        float torque_x = tensor.x * acceleration.x;
        float torque_y = tensor.y * acceleration.y;
        float torque_z = tensor.z * acceleration.z;

        return new Vector3(torque_x, torque_y, torque_z);
    }

#

This does not work if the input vector is of the form [0,0,z]

timid dove
#

AddTorque accepts a forcemode argument

prime rain
timid dove
#

I'm not sure how that's relevant to the code you posted or what you said before

prime rain
timid dove
#

Inertia tensor is a local space thing for the Rigidbody

prime rain
elder swift
#

Well, without that I'm a bit stumped. I created a new project with two objects and there is no gap. Simlar settings that you have except I zero'd the offsets. Without seeing specifics of the projects, I can only throw guesses at you. Like try zero'ing the offsets. What is the scale/ie, how zoomed in are you? I will say this, Iapinozz said could be true. It could be magnified if your scale is quite small. Look at this sample I built. Looks good, but you see there is a gap. My offset is zero. now, That could be eliminated by changing offset and he is right, Unity does keep a small gap and that's intentional to keep things from "falling" through the floor.

#

see above, sorry I forgot to hit reply

#

If the colliders get too close for physics to calculate in time, things will pass through that aren't intended to pass through and weird stuff happens. Moving your offset won't cause that, it will just help your player be closer to the "floor".

#

if you take the default gap unity adds, plus your offset, divided by the scale of your project, that could be your result.

civic field
#

imma just give up and hope i dont run into it again

#

mustve messed something up

raw yarrow
#

Goodnight guys, I have some domino tiles on a makeshift table (plane) that I want to react to one domino. That one domino would come down on the table so hard that it causes the rest on the table to move (like what slamming something on a table does to other objects on it). However, I am stuck as to how I would go about implementing this effect. Any pointers? Thanks!

brave geyser
#

Hi, I am making a 2d platformer game based on physics. player needs to jump over some hanging planks to cross some areas. I did all moments of player with forces, problem is that when player is on hanging planks the planks are moving by player...player can not be on plank, also plank gets parent for the player while player is on plank. I do not understand the problem. plz help

brave geyser
carmine basin
#

I did something kind of similar

#

What you'd do is either OverlapSphere or sphereCastAll to get all of the dominoes in the area you want to affect with this impact
then using a foreach loop, you can one-by-one do your addExplosionForce method to the rigidbodies.

viral ginkgo
#

@raw yarrow You can get the collision points as well, in your OnCollisionEnter, you should also be able to get relative velocity for each collision point

raw yarrow
raw yarrow
stuck needle
#

How can I make something like Tribes Ascend's core mechanic in Unity 3D?(Im still a begginer)

rough lodge
#

I'm having an issue. Whenever I'm right next to a slope, the raycast I'm using thinks I'm at the slope and thus I can't move my character

    {
        Vector2 CheckPos = GroundCollider.bounds.center - new Vector3(0, GroundCollider.bounds.extents.y);
        //Debug.Log(CheckPos);
        SlopeCheckHor(CheckPos);
        SlopeCheckVer(CheckPos);
    }
    void SlopeCheckHor(Vector2 CheckPos)
    {
        RaycastHit2D Front = Physics2D.Raycast(CheckPos, Vector2.right, GroundCollider.bounds.extents.x*3, LayerMask.GetMask("Ground"));
        RaycastHit2D Back = Physics2D.Raycast(CheckPos, -Vector2.right, GroundCollider.bounds.extents.x*3, LayerMask.GetMask("Ground"));
        if (Front)
        {
            onSlope = true;
            SlopeSideAngle = Vector2.Angle(Front.normal, Vector2.up);

        }
        else if (Back)
        {
            onSlope = true;
            SlopeSideAngle = Vector2.Angle(Back.normal, Vector2.up);
        }
        else
        {
            SlopeSideAngle = 0;
            onSlope = false;
        }
    }```
this is my raycast's code
runic surge
#

I need a byte serializer/deserializer for a physics object cloner in a modified Farseer Physics Engine. Looking to pay someone talented for this, PM me

frail plinth
#

has anyone used puppetmaster with the newest unity version? nothing seem to work. muscles are all over the place

#

whats wrong with my prop muscle?

frail plinth
#

if only unity had its native ragdoll tool. now i have to go back to unity 2020 because there are so many bugs now with puppetmaster

frail plinth
#

so pls unity buy puppetmaster, or create your own tool and keep it updated! its an essential tool!

frigid lagoon
#

Do you guys know any free alternative to Dynamic bones ?

frail plinth
frigid lagoon
#

Allow you to define how a chain of bones behave when their attachment move arround

frail plinth
frigid lagoon
#

It allows you to define the softness of the material and then it does the rest. Also you can interact with the chain with coliders

frail plinth
frigid lagoon
#

But yeah i guess we can do it manually

frigid lagoon
frail plinth
#

k

frigid lagoon
#

I've seen many games using it.
But i'm trying to make something i can publish the source code from, so i cant use a paid asset

#

Its litteraly the first result in the unity asset store

frail plinth
frigid lagoon
#

Yeah i saw thoose posts. I'm not sure on the second repo if its really something that works without the addon, or if its a placeholder for vrchat creator to setup their bones without the addon

#

I'll try that though thanks

frail plinth
frigid lagoon
#

Oh, yeah you're right !

#

I didnt think of that

#

they wont be able to like build the source, but for modding kit its probably enought

frail plinth
# frail plinth whats wrong with my prop muscle?

i figured this sht. i need a parent constraint for my weapons that are not a propmuscle(cant child them to a metarigg object). if i set a gameObject as a child of a animation target(under metarigg section) the muscle go totally crazy. why is that suddenly appearing under 2021.2?

trail sphinx
#

when I generate a map for my game, its made up of tiles with box colliders for the ground. These ground tile colliders line up perfectly (as far as I can tell), however when crossing the boundary between them there is sometimes a collision, as if there is a "lip" between them. It messes up player and enemy movement briefly. Is there some easy way to fix this? Im guessing I could instead generate a continuous mesh for the ground, but it seems like a lot of effort

jovial wraith
#

if you're using a tilemap for your tiles then using a tilemap collider is probably a good idea and should solve it, too

trail sphinx
#

ive never heard of tilemap, ill look at that

jovial wraith
#

it sounds like you're working in 2D, so making edge colliders so you have one big continuous collider shouldn't be that hard, either

trail sphinx
#

its 3d

jovial wraith
#

ah, well then I'm not sure tilemap will be a good fit either

trail sphinx
#

overlapping didnt really work, now it seems like there are 2 lips 😦

little flicker
#

Anyone know how to stop rigidbodies on moving objects from doing this ?

timid dove
little flicker
#

Sorry 😅 I'd like the rigidbody on top of the moving platform to stay positioned stationary relative to the platform. Not pull back from the forwards velocity

stuck bay
#

here's the workflow I've been trying to get under control. I have the cape in blender with other objects on the main rig. I send it to unity, I make it a prefab, I take off all the other objects but leave the rig and the cape. then I add the cloth component to the cape. I set constraints on the top of the cape to let the bottom flow smoothly. I then build slots/overlay/recipe for it and put it on the character. the problem I'm having is the cape bunches up together on the bottom and doesn't really flow when he runs, it just kinda flaps side to side.

stuck bay
#

also the cape swings around his neck a bunch

runic surge
#

Does anyone here believe that that Unity's physics engine (or any C# physics engine that uses floating point math) is cross-platform deterministic? I'm fully aware that it is NOT deterministic, but recently another developer asked me this question so I figure I'd ask the community.

viral ginkgo
#

@runic surge Big source of nondeterministic behaviour in rollback networked games is not being able to full replicate the state the of the physics simulation

#

That'd be the internal states held in the physics engine other than velocity, angular velocity, position, rotation

#

If you want to totally avoid state transferring, you'd probably wanna use fixed points
But if you'll be having some state transferring, then unity.physics, a stateless floating point physics engine should be fine

#

The chaos that's produced by the floating point processing divergences might be negligible for some sort of games I think
Maybe you can avoid state syncing

#

Or sync the states every 5 seconds to keep the divergence in check

pastel basalt
#

!help

stuck bay
#

if you have more than one collider on an object and you use that one object on the cloth component will it register all colliders?

glass nexus
obtuse frost
#

Mathf.Infinity using the System namespace?

obtuse frost
#

Situation: I want to make drag-and-drop elements in / for a GUI. Would it be better for optimization or development to simply calculate the movement and rigidbody physics inside a separate collision group (e.g. , and not inside a Canvas object? If possible, I'd like to calculate physics with the drag and drop elements. If any further clarification is needed, please tell me so I can elaborate further in future questions

unique cave
#

What you mean exactly? You don’t mean unlimited as infinity ig. You can put any numbers on the Quaternion.Euler, it’s not limited to [0, 180] range

#

It’s either me not understanding or your question being unclear. It seems skary didn’t understand you either…

west scroll
#

!help

#

Hello guys. I have been running into this problem for a while and I thought that I could get some help. The issue is that wheel colliders just fall thru the ground. I don't know why. When I place them beside the car they work perfectly but when I put them back they just fall down as if I didn't have wheel colliders. Here is a screenshot of the properties:

little flicker
vocal steppe
#

If it's such a no-no to directly modify the velocity of a Rigidbody, what's the best way to make sure the entity does ever move faster than we want it to?

In my case it's a character that I'm moving, it has a max run speed. I'm using AddForce to move it because I DO WANT acceleration and braking (not just instant movement and stopping).

#

Most solutions I find online are doing it the no-no way of just setting the velocity directly if it's greater than the limit.

bleak umbra
# vocal steppe If it's such a no-no to directly modify the velocity of a Rigidbody, what's the ...

Such limits are a valid post process to apply to velocity. In most cases though it ends up being simpler to make a kinematic motor/controller that inherently follows the right rules vs you fixing a realistic simulation to become unrealistic but more fun. This velocity no-no attitude is mostly grounded in this observation and the assumption that whoever sets velocity directly (in this discord) doesn’t know how to use physics correctly.

#

The only situation where you would use simulated physics (forces) is when you need complex interactions of objects (collisions or other forces) that are realistic and with little to no changes to the default behavior.

vocal steppe
vocal steppe
#

Well..."implementation".

bleak umbra
#

it depends on the design of your game. Maybe sim physics are the right way for you

#

Either approach is eventually a bunch of work and you kinda need to guess which one will cause you less trouble

plain oriole
#

i added a kinematic rigidbody and box collider and i have a navmeshagent using setDestination to move to where the cursor clicks. I read in the docs that a kinematic rigidbody can be used with navmesh but it's not moving

plain oriole
#

So looks like the mesh the collider is on cannot have a parent... is this a bug?

edgy solstice
#

Hey everyone, does non-convex mesh collider, without rigidbody, is still cost expensive?
Because after couple collisions with it I would replace that object with cloned objects with sphere colliders and rigidbody.
Not sure if that's way less performant than making couple of sphere colliders instead of mesh one

timid dove
edgy solstice
#

That's what I thought, I just have a mesh collider on a object without rigid body, so it won't be moved at all, just detect collisions if player like run into it.
@timid dove thanks

daring dew
daring dew
#

If not on the root object try again by adding it on root object

#

Or try capsule collider

bleak spire
#

Having trouble getting ontrigger2d to fire. One object has a collider2d + rigidbody2d and is set to IsTrigger. The other object has a collider2d. I have a script setup on the object that has the rigidbody that has the OnTrigger2d function with a debug.log printout. I drag the objects into each other and the script doesn't fire. Anyone see something obviously wrong here? Of note: I made these objects and attached everything while the editor was running, don't know if that matters?

bleak spire
#

nvm think I figured it out

#

Those 2 objects were already inside another collider, so ontriggerenter2d had fired earlier

quartz tartan
#

Okay, so i've been trying to remove collision between two rigidbodies connected by a joint. one is kinematic, with only a box collider and the other is made of a compound collider. Initially i just tried keeping "Enable collision" false, which did not work. I then tried removing collision when the joint is added, and adding it back when the joint is removed

//sets whether or not the hand's colliders will collide with col
public void IgnoreCollision(Collider col, bool Active) 
{
    Debug.Log("Ignoring collision between " + col.gameObject.name + " and " + gameObject.name);
    Physics.IgnoreCollision(HandCollider, col, Active);
    Physics.IgnoreCollision(FingerCollider, col, Active);
}
#

this also did not work. i don't want to use layers, as i could have two objects grabbing one object, and as such would need a layer for each hand, and three layers for the potential grab states(LeftNoCollide, RightNoCollide, BothNoCollide. don't need a fourth as we can just use the layer the object was already using for that)

#

what might be going wrong? what should i do? any help is appreciated!

#

i should add that disabling the colliders, while a potential solution, does not work in my case as i would still like the hands to be able to collide with other things

tough geyser
#

Hello, I am changing a joint's connectedAnchor from a script but the joint wont get updated unless I select the item in the editor or move its rigid body, it seems physics are sleep thus the joint is not updated. Do you know how to force physics to wake up? Thank you

daring dew
#

if it is kinematic

tough geyser
daring dew
#

Try Rigidbody.Wakeup

#

Rigidbody.Wakeup() just before the code for changing the anchor

timber pelican
#

anyone know why my raycast detects my model when it's from from WITHIN my model?

#

i imported the model via .fbx, but did not check "generate colliders" on the import settings. but the trigger fires everytime it starts from within the model mesh. it's like the model came with a hidden mesh collider, but i can't find it

timid dove
timber pelican
#

yeah, I have. it keeps printing out the name of the gameobject from within which the raycast is fired from.

#

until i move the starting point of the raycast out of the model, then it works fine. it's not the mesh of the model, looks like it's colliding with the bone of the model, but the bone seems to have a hidden collider?

#

nvm i know the issue, it's colliding with an external collider on that gameobject, so looks like my collision matrix isn't right.

tough geyser
quartz tartan
#

any ideas why two rigidbodies connected by a configurable joint could be colliding?

runic surge
#

but thank you for your response - I appreciate it

steep bison
#

I'm making a sort of doom/Quake style game and I'm looking for advice regarding my map's collision. Currently I'm using a set of mesh colliders for each room. I made a basic version of the map for mesh collision detection. My problem is that I keep seeing that mesh colliders are terrible and that I should use box colliders. Is it worth spending the time to box collide everything or should I stick with the basic version of my map with mesh colliders?

daring dew
unique cave
stuck bay
#

Hello guys

#

i dont know why my left wheel is like this

#

if someone can help

timid dove
#

Like what?

stuck bay
#

Like my screen

#

is reverse

#

right side

#

left side

timid dove
#

So turn it around?

#

Is it a separate object?

#

Share some more details

stuck bay
#

no

timid dove
#

so which object are we looking at

stuck bay
#

is not that

#

when i spawn

#

the left wheels spawn like my screen

timid dove
#

Seems like you have a separate object for the collider and the "Wheel Transform"?

stuck bay
#

yes

#

wheel transform is the merche

timid dove
#

merche?

stuck bay
#

and i dont know how my collider need to be

stuck bay
timid dove
#

Just position them properly - not sure what else to say

#

Move them to where they need to be

stuck bay
half blaze
#

hello why I cant send code block

half blaze
#

I know how to send it doesnt let me

#
void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == ("Player"))
        {
            ScoringSystem.theScore += 100;
            SaveManager.instance.money += 100;
            SaveManager.instance.Save();
            Destroy(gameObject);

#

Hi I have multiple objects with mesh collider and they are using same tag .I have this scripts that detects it and gives a score but I wanted to give only 100 score but it gives multiple because some cars have 5-6 mesh colliders how I can make it detect multiple and gives 100 every time ?

half blaze
stuck bay
#

Someone can help me with the collider please

#

i dont know why my left wheel is like this

#

i dont know if is a colliderr problem

#

my left wheel car collider is reverse

viral loom
#

So this is probably the noobest of questions, but I'm taking a Unity class to finish my software dev certificate, and I'm trying to make a 2d virtual pinball game for the final. The physics seem to LARGELY work fine, but when I try to use the flippers to hit the ball back up the table, a lot of the time it sees like the flippers miss the collision entirely--like one frame they're below the ball, next frame they're ABOVE the ball, but the ball just keeps going like it was never touched. I get the feeling that this may be because I'm moving the flippers by changing the Z rotation by 15 degrees every frame until they get to their top position (since that feels roughly about how quick flippers on a real pinball table move), so unity MAY just be calculating the discrete positions, even though I've enabled "Interpolation" on the flipper rigidbodies and "Extrapolation" on the ball's rigidbody. But I'm sure there has to be some kind of way around this because games do stuff like this all the time?

#

Unfortunately I can't send my code, because we all have to use Visual Scripting for this class, and I hate it. At least C# is helpful with its debug logs. 🙄

viral loom
timid dove
viral loom
stuck bay
#

Top = Right Side

#

Down = Left side

#

Look the wheel you will understand

viral loom
# timid dove You need to move the flippers in a physics aware way like MovePosition/MoveRotat...

"Rotates the Rigidbody to the specified angle by calculating the appropriate angular velocity required to rotate the Rigidbody to that angle during the next physics update. During the move, angular drag won't affect the body. This causes the object to rapidly move from the existing angle to the specified angle."

hm. so does this "teleport" to the angle in one frame while also calculating the physics, or is there some sort of way to control the speed of this movement

viral loom
# stuck bay

So the tire meshes are also in a weird place, as well as the colliders?

viral loom
stuck bay
#

i have wheel transform and wheel collider

#

Hello guys

#

i need help

#

i have created a car

#

But the left side of the car for the wheels is reverse in game

#

i dont know why

#

he need to be like that

carmine garnet
# stuck bay

I am not so sure but... you might want to check the normals on the modeling app (like blender perhaps)

fickle aspen
#

Is it bad to scale a mesh to crazy large sizes? Should I be making them large in Blender then exporting them so they're not such a large scale?

#

If this isn't the right channel, my apologies. Does this harm performance?

tough path
#

Is the Havok package just slightly usable in a project?

#

All I need is a solid Rigidbody for my player because Unity's is really unreliable it turns out

#

I don't need any debugging tools, just a player rigidbody and that's it

#

Can Havok provide that in its current state?

bleak umbra
fickle aspen
prime flower
tough path
#

Specifically the OnCollisionEnter/Stay/Exit

#

They're very random it seems

#

and there's just a lot of features that I'd like to have

#

but dont

bleak umbra
#

Compared to Unity Physics simulation, Havok Physics for Unity offers:

Better simulation performance: Havok Physics for Unity is a stateful engine, which means simulation time is over two times faster than Unity Physics in scenes that have a significant number of rigid bodies. This is due to automatic sleeping of inactive rigid bodies and other advanced caching techniques.
Higher simulation quality: Havok Physics for Unity is a mature engine which is robust to many use cases. In particular, it offers welding, a feature that allows for stable stacking and for smoothing out contact points when rigid bodies slide quickly over each other.
Deep profiling and debugging of physics simulations using the Havok Visual Debugger (only available on Windows). This industry leading tool can help you identify fine-grained, real-time multithreaded performance data that shows exactly where cycles are spent across all cores of the target system.

tough path
#

Right

#

But is that in its current state?

#

Because I'm pretty sure the package is only at around 0.1.2

bleak umbra
#

also you can read all that in the docs yourself

tough geyser
#

Anybody has a good knowledge resource or tutorial on ArticulationBody? I appreciate any help

tough geyser
#

One of the things I cannot figure out is why I cannot move an ArticulationBody

#

Is like something else is updating the position of the root object

jovial wraith
#

with character controller, if you want to move it using the transform component (ie warp its position instead of moving normally) you need to disable the CC or call Physics.SyncTransforms() after your move

#

otherwise the CC thinks the object is in a different place than the transform thinks it is, and the CC drives the transform's position so it just snaps back to where it was

tough geyser
#

Thanks, this is intended to be used with direct manipulation, e.g. the Player grabbing this chain in VR

jovial wraith
tough geyser
#

because I have spent 1 week trying to make joints stable but they still explode

#

I was told to look into articulation body as they say are more stable

#

I have done an extensive research on joints and ways to stabilize them

#

but still on long complicated chains they break and explode

#

specially with direct manipulation, even if this manipulation happens in FixedUpdate

jovial wraith
#

yeah, the problem with direction manipulation is that you move things outside of the normal constraints of the physics system

#

and it requires huge forces to fulfil the constraints in the physics system

#

if its possible at all

#

what's the chain for?

#

depending on what you need it to do, verlet integration might be a better way to go

tough geyser
#

Thanks, its not really for a chain but for a physics blendable soft sword simulation

jovial wraith
tough geyser
#

both

jovial wraith
#

okay, verlet might be hard then

tough geyser
#

So figured out the ArticulatedBody root can be moved with a physics joint

#

problem now is that I go back to my initial point of failure

#

which is that joint breaking because the Articulated Rig wont concede

#

Thus something has to give up and is the joint

jovial wraith
#

I wonder if you disable Compute Parent Anchor and then set the anchor point to the position of the GO you're moving every fixed update if that'll be stable

tough geyser
#

I can try that

jovial wraith
#

or... actually, I'm not sure that would do what I thought at first

#

you can try it, but I think it might just not move

tough geyser
#

wait, yeah

#

the root doesnt have a parent anchor

jovial wraith
#

yeah, I'm saying do it more like IK

tough geyser
#

the root AB (articulated body) doesnt have a parent anchor

jovial wraith
#

have a target that you're trying to follow

tough geyser
#

it is being grabbed now with a joint

#

so you mean modifying the transform of the AB root on FixedUpate?

#

I can try that

jovial wraith
#

I was saying have 2 objects. A target, and the AB root. in FixedUpdate you drive the AB root toward the target (not quite sure how--this is the part that wasn't thought out well)

#

but you only manipulate the target directly. The physics system does everything that moves the AB root

tough geyser
#

yeah, setting the transform on an AB root would do nothing as it is being overwritten by the AB itself as you said

#

not sure how to drive it

#

just tested it

#

I guess that is what a Fixed joint would do

#

but fixed joint breaks

jovial wraith
#

can you screenshot your root AB inspector?

tough geyser
#

Ignore the Follow Script, this is what I just tested but doesnt work

#

I have been trying to find ways to stabilize Joints, one of my attempts was to clamp the position of the bodies on Fixed Update, this seems to work but as pointed out by someone it can lead in sometimes the objects hitting other colliders with massive forces

jovial wraith
# tough geyser

okay, crazy idea. You have a root AB that is fixed at a specific place in the world (immovable), and this object becomes the first child of that. You use X/Y/Z Drive to move its position, give it another child that has a sphere joint to do rotation

tough geyser
#

interesting

#

so who is first child of who?

jovial wraith
#

immovable (root) > position > rotation > your current chain

tough geyser
#

all of them ABs?

jovial wraith
#

yeah

tough geyser
#

wont work

#

Abs are aware of the hierarchy

#

so the root will become the immovable

#

but what I can try

#

is that but the child 0 would be driving position and child 1 will work as a hinge

jovial wraith
#

no, you move the position AB using a prismatic joint

tough geyser
#

then the rest can be the chain as I have it

#

ahh

jovial wraith
#

I guess you might need 3

#

and you'd be moving it like it was a motor. So you'd have to feed forces into it rather than a position

#

this would not be a simple system

#

but it is a lot closer to how AB are supposed to be used

tough geyser
#

That could be very difficult if I want to match the exact position of the VR Hand by just using forces

#

I think I could automate a rocket landing if I could figure that one

jovial wraith
#

yeah, its a classic controls problem. Big thing in mechanical engineering

tough geyser
#

even harder, It is like automating a ship landing in a comet x)

#

match the velocity of the moving hand with forces at all times

jovial wraith
#

yeah, I don't think AB are going to make your life easier for this problem. They're designed to better simulate real world physics, but moving the root outside of unity's physics simulation is an inherently non-physical situation.

tough geyser
#

yeah I see that

#

but looking at it now I have 1 joint that breaks rather than having a rig of joints that could fail

#

if I find a way to stabilize this joint

#

any guess on stabilization?

#

I can try clamping the position again

jovial wraith
#

I'm not sure... trying to detect when the joint has broken and trying to calm the simulation down in that case might be what I'd try

#

like... if the velocity exceeds some threshold, turn off all the ABs, reposition everything, turn them on, then call Physics.SyncTransforms

tough geyser
#

yeah I have tried that, zeroing all forces and reseting the position

#

will try that again

#

Thanks a lot for the help

jovial wraith
#

yeah, np

#

its an interesting problem

tough geyser
#

it is!

tough geyser
#

Im getting this weird error
A joint can't connect the body to itself.
When removing the connectedArticulationBody from the joint by code
_joint.connectedArticulationBody = null;
Not sure why it is complaining

austere merlin
#

why does this hinge component go beyond its limits?

#

not only that it starts in this position

sudden bay
#

Hi, so I want to make a 2d swinging mechanism on ropes, but I don't really have a clue how. When the player is near a block that has the layer on it like an ID, it will launch a grappling hook onto it. So it's not just where the player wants randomly in the air but on a specific thing.

hoary edge
#

It should be rotating between -90 and 0

hoary edge
#

If I disable preprocessing nothing happens, enabling collision has no effect either

#

Freezing everything apart from the Z axis causes the correct rotation but it does the same thing in the center of where it should be

timid dove
#

Looks like you need an exorcist

hoary edge
#

I remade it and now it just doesn't move 😦

winter walrus
frail plinth
#

anybody around? how would you create a shopping cart driven by a ragdoll?

zealous quartz
#

hey guys im very very very new to unity and i was trying to make a rigidbody and it gave me this error

#

can someone tell me why it says this and how i can fix it

bleak umbra
zealous quartz
#

ok

lilac garden
#

When a Raycast is fired from Update, is it still calculated in FixedUpdate/Fixed Timestep?

unique cave
dense storm
#

Is there any limit to torque added by AddTorque();

dense storm
tawdry oasis
#

Im making a punching bag (2d)
The bag consists of the bag itself, a chain connected to the bag as well as the plank connected to a wall (see picture)
How can I make it so the bag and chain react to punches on the bag while simultaneously making them all look connected to each other?

pearl crater
#

Hey, currently I have this as my player movement script

body.velocity = new Vector2(Input.GetAxis("Horizontal") * Speed, body.velocity.y);

And I have a material on my RigidBody2D that is set to 0 friction when touching a wall. I can confirm this when I look at the Material in the inspector. However, my character sticks to walls when I hold d towards a wall on the right or a for a wall on the left, regardless of this. What am I doing wrong here?

timid dove
#

in 2D friction is always averaged between the two objects

pearl crater
#

The wall is also set to have 0 friction

#

it also has a rigidbody2D

solid mortar
#

hi can someone please tell me why I cant I disable the rigidbody component

coral silo
#

How to create a magnet like effect when an object is near to the magnet

drowsy needle
coral silo
nova verge
#

Hey how do I make that BoxCollider2D detects collision but when object rides into it, it won't affect it, only detect collision and not slowing object ?

tough notch
nova verge
#

yea

#

and also

#

i am using in other object trigger

#

and it triggers other function

#

when I am using ontrigger

#

so how to separate them

#

and

#

how to make collider doesn't affect speed of object, collision

#

like a ghost collision

tough notch
#

You'll get collision/trigger events on anything with a Rigidbody, so remove the RB from the object you dont want the events on

#

Maybe I'm misunderstanding you, the second part just sounds like a Trigger again

nova verge
#

hm

#

I will try

#

Oh instead of having interaction script on object, i had it on car bruuh

#

yay it works now

#

thank

#

you

latent violet
#

how does one make a bounding box to hold numerous flying objects within it

#

i am trying to see if i can confine a boid simulation within a transparent cuboid

#

*translucent

agile kernel
#

Hey people. Rigid body setup does collide with colliders, but never registers OnCollisionEnter. Any help?

pearl crater
#

For what reasons would my physicsMaterial2D NOT be affecting the rigidbody2D I put it on??

#

like the paramaters just do nothing when updated in the script

#

on start if the bounciness is set to 1, the rigidbody will bounce

#

however if something in the script sets it to 0, and I can see in the inspector that this works, it just wont affect the rigidbody

#

and no matter what, friction just won't affect the rigidbody.

#

actually, just set the friction to always be 0 and it works. however when I try to change it in a script, it changes the material but no longer affects the rigidbody properly. (it seems to be setting to default parameters, as the friction lets me stick to walls and I don't bounce anymore.)

#

I did a bit more testing, if I set the friction to always be the same, it works fine. if I change the bounciness in a script, it stops working but friction still stays whatever it is constantly set at. Vice versa for changing friction, bounciness still works fine.

pearl crater
#

Apparently this is a bug that has been around for 7 YEARS?

#

what

#

the fuck

#

I swear this should be used often enough that every single person has to have found out about it

#

what the heck

glass nexus
#

unreal is better 💪

unique cave
glass nexus
#

unreal is better 💪

frigid pier
#

@glass nexus Don't spam the channel.

#

@pearl crater Make sure you are accessing the correct referenced object and it's not a cloned property issue.

pearl crater
#

I definitely am, I'm dragging it in editor.

#

apparently you cant change physicsMaterial2D properties during runtime

frigid pier
#

When you accessing it in the script

pearl crater
#

or you can change them, but not apply them

pearl crater
frigid pier
#

You probably mixed up about struct properties. Entire struct object has to be initialized to assign

#

When you change struct property on the object you don't actually change it on the object

#

Same thing when you need to access position. Transform.position.x is a struct property, assigning it won't do anything unless you create new Vector3 to swap

pearl crater
#

so how would I initialize a PhysicsMaterial2D properly??

unique cave
#

@pearl crater have you tried disabling and enabling the collider adter changing the friction?

pearl crater
#

I can't do that, it would screw up a lot of other code.

unique cave
#

How so?

frigid pier
#

Doesn't look like it's a struct issue, likely you have some mix up with the reference, or physics object indeed has to be refreshed somehow.

#

@pearl crater Just tested it. Doesn't matter code or in the inspector Collider2D holds on to the previous instance of the physics material and it doesn't trigger refresh until you toggle off/on the collider

pearl crater
#

alr. I figured it out though anyways, thank you

frigid pier
#

Same thing in 3d btw. So it's an expected behavior.

#

I haven't tested if the same happens if you assign the same material again.

#

It might trigger object update properly

odd bear
#

is there an efficient way to make a custom physics system without iterating over literally every other object

unique cave
#

Why you need custom physics engine?

unique cave
odd bear
odd bear
#

what i mean is that my moving platforms are made of the same stuff as my walls atm

timid dove
unique cave
#

I think some sort of aabb tree could work for dynamic objects too

odd bear
#

oh yeah, i should have mentioned that its aabb only

unique cave
#

With binary tree type of approach you could probably repeatedly split the scene into smaller pieces (aabbs) so you dont need to iterate through all the objects

odd bear
#

thank you for the input

#

ill do some research

lapis plaza
#

The more physics objects you have there, the less likely you are to get any gains over builtin physx. Also would suggest looking into contact modifications on unity 2021 lts if needing bit more control.. And actually understanding how physics engines work so one can design systems that work nicely

#

@odd bear ^

#

If you still need more control, there are bullet physics wrappers for unity with full source access.. And dots version aka unity physics that ships with full c# source code and lots of physics solver stages you can manually adjust/spoof out of the box

#

DOTS physics use ECS though so that is not for everyone or every use case

#

Just trying to say that there are alernatives to just doing same thing from scratch - unless the whole point is to just learn how to build these things

#

In majority of cases doing your own physics engine is just overkill and is likely to be way slower

mental mica
#

hello, i'm not sure if this is the right channel, but i have a game idea (related to physics), where you can go around the maps to change physics constants and equations

#

maybe to solve puzzles

#

but 100% of physics is just too hard, so i think ill make the part that affects movement

#

not all the ones that affect movement, so no temperature etc, unless someone wants to give that a try

tawdry forge
#

Hey, trying to use .FBX file that I have exported from Blender, but when I'm trying to use the Rigidbody component, it says

Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5.```
Any help?
unique cave
tawdry forge
unique cave
#

Depends on the mesh, its very common to make the collider out of multiple primitive colliders (aka compound collider) like box, sphere and capsule colliders

kind pilot
#

how do i make a standing ragdoll?

golden nymph
#

Its possible to have multiple Fixed Update methods for physics? For example far objects have 30 tics per second and close objects have 60 tics per second.

bleak umbra
# golden nymph Its possible to have multiple Fixed Update methods for physics? For example far ...

you can do something like this (code below), but physics will always run at the globally defined update rate, usually you'd disable physics entirely for distant objects and maybe use kinematic interpolation.

long _fixedFrame;
float nextSlowUpdate;
private void SlowFixedUpdate(float dt) {

}

private voud FixedUpdate(){
    if (_fixedFrame % 2 == 0)
        SlowFixedUpdate(Time.fixedDeltaTime * 0.5f);
}

private voud FixedUpdate(){
    if (nextSlowUpdate <= Time.fixedTime)
    {
        SlowFixedUpdate(slowInterval);
        nextSlowUpdate = Time.fixedTime + slowInterval;
    }
}
golden nymph
#

I did something like that and Its apparently making far objects fall slower.

bleak umbra
#

if you apply your forces in that kind of slow update you apply less force but the sim still runs at the speed

#

you gain close to nothing by doing that

golden nymph
#

I see.

dapper eagle
#

The friction force is calculated using the force pushing an object into the surface right?
Like gravity pushes the player into the ground so that force is used to add friction (multiplied by the coefficient from the physics material)

#

or does unity/physx do it differently

jovial wraith
# dapper eagle or does unity/physx do it differently

https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Manual/RigidBodyDynamics.html#friction-and-restitution

Friction uses the coulomb friction model, which is based around the concepts of 2 coefficients: the static friction coefficient and the dynamic friction coefficient (sometimes called kinetic friction). Friction resists relative lateral motion of two solid surfaces in contact. These two coefficients define a relationship between the normal force exerted by each surface on the other and the amount of friction force that is applied to resist lateral motion. Static friction defines the amount of friction that is applied between surfaces that are not moving lateral to each-other. Dynamic friction defines the amount of friction applied between surfaces that are moving relative to each-other.

looks like it does it the way you described (more or less)

kind pilot
timid dove
midnight geode
#

Is there a way to make a rope kind swing after the player jumps on it or starts to climb? I'm using a 2d hinge joint rope. If anyone needs code or to see how the rope is setup I can send screenshots, much appreciated!

real thunder
kind pilot
#

how do i make it stand?

arctic flare
kind pilot
#

well will it still be interactable with animations?

#

when i tested it, its kind of janky and returns to the animation pretty quickly

stuck bay
wooden summit
#

How i can create collision between cloth with mesh collider object ?. In documentation cloth only work for sphere and capsule collider.

distant crane
#

I followed this tutorial https://www.youtube.com/watch?v=p8e4Kpl9b28 to make a trajectory line for my game (a 3d version of castle crusher). In the video he used obstacles that didn't have rigidbodies, but my game has rigidbodies and they keep flying all over the place when I run the game. If I create a physics scene
_simulationScene = SceneManager.CreateScene("Simulation", new CreateSceneParameters(LocalPhysicsMode.Physics3D));
can the objects in the physics scene interact with my normal scene?

#

The blue dots are the trajectory path. The first screenshot is before I press play, then second is after a second or two.

thorny basin
#

Hi, how would I be able to reset my articulation body to a previous state ? I have something that stores position, rotation etc and replaces it at runtime but it doesn't move

distant crane
timid dove
distant crane
#
    public void CreatePhysicsScene(GameObject ballPrefab)
    {
        _ghostProjectile = Instantiate(ballPrefab);
        _ghostProjectile.GetComponent<Renderer>().enabled = false;
        _simulationScene = SceneManager.CreateScene("Simulation", new CreateSceneParameters(LocalPhysicsMode.Physics3D));
        _physicsScene = _simulationScene.GetPhysicsScene();
        SceneManager.MoveGameObjectToScene(_ghostProjectile.gameObject, _simulationScene);

        foreach (Transform obj in _obstaclesParent)
        {
            var ghostObj = Instantiate(obj.gameObject, obj.position, obj.rotation);
            ghostObj.GetComponent<Renderer>().enabled = false;
            SceneManager.MoveGameObjectToScene(ghostObj, _simulationScene);
            if (!ghostObj.isStatic) _spawnedObjects.Add(obj, ghostObj.transform);
            if (ghostObj.TryGetComponent(out Destructable destructable)) Destroy(destructable);
        }
    }
#

This is pretty much straight from the tutorial, although I changed it so it doesn't instantiate the ball fresh every time so a few lines are different.

#

I've just noticed there is one wall (an empty object with several of those pillars as children) that pops up when I run the game. I don't understand why there would be just this one object that is being put in the world while all the others are going in the simulation scene.

#

Got it! So it was throwing an error that I have been ignoring, but now I realize that it was important. Some objects don't have a renderer, so where I was doing .enabled = false it would error out of the function and the part where it was moved to the physics scene wasn't running.

timid dove
#

Also instead of manually moving the objects to the other scene you can set the other scene as the active scene. Then Instantiate will put them directly in that scene

timid dove
# distant crane ``` public void CreatePhysicsScene(GameObject ballPrefab) { _gho...

So like in this method you could do this:

_simulationScene = SceneManager.CreateScene("Simulation", new CreateSceneParameters(LocalPhysicsMode.Physics3D));
Scene oldScene = SceneManager.GetActiveScene();
SceneManager.SetActiveScene(simulationScene);

// the rest of the code here with all the Instantiates

SceneManager.SetActiveScene(oldScene);```
#

Then you wouldn't need any of the SceneManager.MoveGameObjectToScene stuff

#

Just a thought 😛

harsh osprey
#

I'm having some trouble with my springjoint. It's bouncing me away from the object even though i have minimum distance set to 0, why would this be happening?

weak mural
#

Anyone have any experience with Physics.OverlapBox?

#

Cant get the boxes to rotate, the red is boxes marking themselves as colliding with that block, the transform is slowly rotating and im setting the rotation of the collider to that rotation:
Collider[] hitColliders = Physics.OverlapBox(castCenter, castSize/ 2, transform.rotation, groundCollisionMask.value);

golden nymph
#

Why I cant use Non Kinematic Rigidbody with custom Mesh?

unique cave
golden nymph
#

Man Unity devs have good taste of humour, maybe lets decide ppl if you want it enabled or disabled instead of forcing it off.

#

I decide of performance of my game.

unique cave
# golden nymph Man Unity devs have good taste of humour, maybe lets decide ppl if you want it e...

No, they dont have taste of humour. They decided to upgrade their physics engine to newer and more performant version for unity 5 https://blog.unity.com/technology/high-performance-physics-in-unity-5. One limitation of that newer version is that it doesnt support dynamic concave colliders anymore, I think its worth trade-off tho. You can always make your colliders out of multiple primitive and convex colliders so you can do the same but with less overhead

inland venture
#

Why do I have different rigidbody behavior when I have selected something else in hierarchy?

inland venture
#

Exactly this. https://answers.unity.com/questions/1728313/hierarchy-selection-impacts-game-behavior-why-woul.html

But when I have the object selected it works fine. When I have something else selected. It goes crazy.

timid dove
#

I did not download your mystery file

distant crane
inland venture
timid dove
#

meaning it does different things whent he framerate is different

#

the behavior depends on the framerate

#

If you share your code I might be able to help diagnose why

inland venture
#

Yea, I tried googling that, but didn't found a help.

#

Can I send the code to your DM?

timid dove
#

note that having a Rigidbody inspector open is known to have a large effect on framerate which explains the inspector thing.

timid dove
#

post it here

#

you're almost definitely inappropriately factoring Time.deltaTime into an AddForce or setting velocity.

inland venture
#

Emm.. it's way to big to be posted here it jumps into a *.txt file

inland venture
#

No, I didn't saw that message when you wrote it. Hold on

timid dove
#

when your framerate is faster that will happen more times

#

so the jump will be higher

#

physics stuff like this needs to go in FixedUpdate

inland venture
#

Okay. I hope i will manage to fixed it. Thanks. And sorry for me being stupid

#

yep, thanks that was easy. Still learning. Sorry

dapper eagle
#

What is the most performant way to get the velocity of an object in it's local transform?

#

I am using the velocity for my characters animator and need to use the velocity using the local directions otherwise the characters animations only match on when the rotation is 0

unique cave
dapper eagle
#

I have encountered a weird problem, i have a script where i set my velocity of my rigidbody and also log the rigidbody it's velocity this all seems to actually update but for some reason my character is just staying in place

#

animations and stuff all update but the character never moves even tho it's velocity is like 5 m/s

#

Only the rotation is frozen

#

it does fall slowly (because i always set Y to 0) but it never wants to move forward or sideways

#

I have no clue why this is happening

#
private void FixedUpdate()
    {
        //velocity = body.velocity;
        Vector3 localVelocity = transform.InverseTransformDirection(velocity);
        anim.SetFloat("velocityX", localVelocity.x);
        anim.SetFloat("velocityZ", localVelocity.z);

        Vector3 desiredVelocity = new Vector3(playerInput.x, 0.0f, playerInput.y) * maxSpeed;
        float maxSpeedChange = maxAcceleration * Time.fixedDeltaTime;
        velocity.x = Mathf.MoveTowards(velocity.x, desiredVelocity.x, maxSpeedChange);
        velocity.z = Mathf.MoveTowards(velocity.z, desiredVelocity.z, maxSpeedChange);
        body.velocity = velocity;
        Debug.Log("Updated velocity: " + velocity + "Actual body velocity: " + body.velocity);
    }

This is the fixedupdate function other things i have is just the input in the update function and the rigidbody/animator in awake i fetch

#

It logs my value and all that but i just don't get why it's not moving forward/sideways or anything

#

the character does fall down because of the gravity that still works a little bit but i am stuck

dapper eagle
#

I figured it out lol it was the root motion setting that was turned on

#

It took me a while tho i hope i never forget this mistake again

slim olive
#

would I use quadratic equation if I need to predict where a rigid body will be when it gets launched in the air?

#

I'm trying to make a turret that can hit a moving target in the air

timid dove
#

Parametric kinematic equations

slim olive
#

would it be hard to implement?

timid dove
#

The problem though is that discrete physics simulation like Unity's don't follow perfect parabolic paths

timid dove
unique cave
tough geyser
#

Why Joints even when everything is fixed seem to drag behind the object they are attached if that object is moving?

timid dove
tough geyser
#

on Fixed Updated trough script

split solar
#

I....have a performance concern with a game I'm working on. Can't go into detail about it, I'm under NDA, but

#

Hypothetically speaking

#

Is there any reason why an object in a scene should have both a 2D and a 3D collider on it?

#

My understanding is that this would be redundant at best and a performance problem at worst

crimson grotto
#

Hey I'm having a huge issue with trying to make a flail. For the most part it works, but once you start moving the handle around the chain starts going crazy. I'm using configurable joints with limited angle, and using position drive to keep the links together (I tried setting position to locked but it doesn't even work hanging regular)

crimson grotto
tough geyser
tough geyser
#

It seems a bug since we should not need an extra script to do what a joint is supposed to do

crimson grotto
zealous quartz
#

i made a cube with rigidbody to make a physics object so i can push around stuff. i get an error about non convex geometry and not supported since unity 5 but now that its convex its shaking everywhere on the floor

#

i can push it though which is good but how do i not make it shake around

unique cave
zealous quartz
#

im sorry im very very very new i dont know much about colliders and stuff

unique cave
zealous quartz
#

ok thank you

tough geyser
#

Hello, why physic joints work well when the camera is looking at them but they break as soon as they are no longer in the camera view?

split solar
#

Anyone know if there's a premade tool/library for splitting a complex concave mesh into approximate compound colliders? Crucially, I need to find something that can be used during gameplay, we cannot do the work manually, we're dealing with UGC so there's no way to predict what meshes the player might end up making.

wooden jay
#

I'm trying to put the centerOfMass below the WheelColliders but every time I do it makes the wheels all "soft" and turn into the turns, rather than away like it would realistically. Thoughts?

#

OH WAIT NVM. I completely forgot ForceAppPointDistance exists lmao 💀

tough geyser
modern merlin
#

i have a rigidbody cube standing on a platform with 0 drag, 0 friction and gravity enabled. it is pushed by this script https://gdl.space/atuxuvileb.cpp. now what happens is it stops shortly after the push because of gravity (i think). i need to know the distance it travels. it kinda messes up with my mind like do we need s = vt in a case like this or gravity and velocity is enough? explain where i'm wrong

jovial wraith
plucky gazelle
#

I have this but everytime i press play, the cube falls down extremely fast, could it be the scaling with the mass? putting the mass to 0.0005 doesn't change anything

jovial wraith
plucky gazelle
#

We work in AR and putting normal size would make it extremely big, how can i change that?

jovial wraith
plucky gazelle
#

We changed physics and it worked, but couldn't make it work with changing the camera settings. I guess i'm giong to try with changed physics on the phone and then come back if anything isn't working out yet, thanks for the advice!

plucky gazelle
#

Aight it kinda worked, but after implementing a jump, it falls with high speed again 🥲

crimson grotto
crimson grotto
#

Issue seems to come from angular limits on the joint if I set all limits to 0 then everything works fine (even still has some springiness, oddly)

#

I would still like to use the angular limits, and solutions?

stuck bay
tough geyser
#

Hello, it seems OnCollisionEnter(Collision other) does not gets called when the other collider is a CharacterController. Any idea on how to detect a collision with a Character Controller?

twilit marten
#

Hi!
I'm not quite sure if that's the right place to ask, but I'm currently working on an outer space game with a huge galaxy (Was thinking of 1 unity unit = ~100-1000 metres). My plan was to move the "galaxy" around the, through a rigidbody controlled spaceship and not the spaceship itself, due to floating point precision limitation.
My question would now be, if it is somehow possible to prevent the rigidbody from applying the calculated position/rotation directly to the coordinate system and instead of that, writing it into a custom defined vector/quaternion which I can take for my own calculations? I hope it's understandable what I'm trying to achieve 😄
Thanks in advance!

rare dove
#

Is circle collider or box collider better for a custom 2d character controller?

viral ginkgo
#

You'd have to keep track of your colliders and objects yourself

twilit marten
unique cave
distant crane
#

I want to do a trajectory, but when I use this formula the line is acting like there is way more power than there should be. I've copied and pasted formulas from a couple of places and it has the same effect every time.
return startPosition + (velocity * t) + 0.5f * Physics.gravity * (t * t);
Here is what it should look like compared to what it does:

#

The second image is what it should be.

river meteor
distant crane
#

Looks like what I would expect.

#

Here's a bit broader view of the code.

public override void CalculateTrajectory(Vector3 startPosition, Vector3 velocity)
{
    lineRenderer.positionCount = steps;
    for (int i = 0; i < steps; i++)
    {
        lineRenderer.SetPosition(i, PointAtTime(i * interval, startPosition, velocity));
    }
}

private Vector3 PointAtTime(float t, Vector3 startPosition, Vector3 velocity)
{
    print("Start: " + startPosition + " velocity: " + velocity + " Time: " + t);
    return startPosition + (velocity * t) + 0.5f * Physics.gravity * (t * t);* t;
}

This is called each update by another class.

#

interval and steps are class variables I set in the inspector.

#

interval is set to 0.2, steps is currently set to 50

jovial wraith
distant crane
#

The drag is 0, angular drag is 0.05. I tried changing angular drag to 0 and the projectile still falls a lot faster than the line.

jovial wraith
distant crane
#

Is mass relevant? A heavier object should have a different curve than a lighter one, but none of the stuff I looked at on this used mass anywhere.

#

Would the time steps mess with the curve shape?

jovial wraith
jovial wraith
#

light object and heavy object should have the same curve

#

assuming your setting a starting velocity and not applying a starting force to it

distant crane
#

Oh, I do use add force with impulse. How would that change the equation?

jovial wraith
#

Impulse = Force * time = mass * acceleration * time = mass * (change in velocity) * time

#

so change in velocity = impulse / (mass * time)

#

(though change in velocity has an implicit /time in it, so that part cancels out)

distant crane
jovial wraith
#

you could also use ForceMode.VelocityChange

#

if you don't want to worry about mass

distant crane
#

Does it make more sense to set velocity or add force when shooting a projectile, or are either method common?

jovial wraith
#

it doesn't matter that much

#

it kind of depends on your game which I would prefer

#

if there are lots of different kinds of projectile and I want them to behave somewhat realistically (ie bouncing around and such) then I would probably set their masses individually and tune the force

#

but if I want fine control of how each one flies then I would set the velocity directly instead

#

if there is just one type of projectile I would probably choose to set the velocity because then the number I put in has more meaning to me

#

though if the mass of it is 1 then they will be the same anyway

#

lots of different factors to consider 🤷‍♂️

#

and its just not a big deal either way

distant crane
#

cool, well thanks for the help, I'm working on my final project for a class and this was hanging me up.

jade storm
#

I had similar problems with 2D hinge joints and making some adjustments helped a lot. Not sure if it will yield you good results, but worth toying around with.

sacred hamlet
#

Hello i have a question. I have a 2D Jump and Run game, when my GameObject jumps on an Oblique surface, he jumps twice as high as on a even ground and i dont know why. Does anyone know the reason for that?

timid dove
sacred hamlet
#

I m using the Character Controller 2D from brackeys

timid dove
#

You need another script along with it

sacred hamlet
#

I was following the Tutorial of his YouTube Channel

#

The movement is working fine but on oblique edges my gameobject jumps Higher

timid dove
#

Do you think anyone has the tutorial memorized?

#

Show the code

modest cape
#

so question, why when my bullet speed increases it does not hit properly anymore? i've already set the RB to Continuous and interpolate but it still does not registrate

weary anvil
#

Can anyone tell me why my Rigidbody won't wake up when I change focus? https://vimeo.com/manage/videos/717066509

Edit: Resolved it by adding the velocity on the rigidbody captured the frame before it was deactivated

modest cape
rare dove
#

is TilemapCollider's optimization good?

unique cave
rare dove
#

or does getting all tiles and constantly switching colliders take more ram

unique cave
#

Maybe, but id guess unity have optimized the tilemap to be about as fast as possible

unique cave
rare dove
#

ok

unique cave
#

You can always use profiler to see if physics performance is a problem to begin with, id not bother making anything fancy unless thats really needed

split solar
#

Is it possible to set up a Mesh Collider to only receive raycast hits, but not be used for actual collision detection and physics?

#

Working on a UGC game, having massive performance issues with moderate-sized levels with lots of level objects. Each level object has a Mesh Collider on it for the sole purpose of being selectable with in-game level editing tools. But the physics system is still picking up these colliders and it just absolutely chugs the game to 0 FPS

#

Can't use Is Trigger because not all objects are convex

#

We've run out of Unity layers too so I can't create a special layer just for the mesh colliders

#

....what do I do?

jovial wraith
#

can you turn off or remove the colliders when level editing tools are not active?

split solar
#

Nope, while some level objects in the game are made by our artists, others are procedurally generated with smearable brushes (think, LittleBigPlanet)

#

And those smeared objects could be literally any shape

#

Convex or concave

jovial wraith
#

that doesn't mean you cant split them up, just that its a little harder

split solar
#

I CAN turn off the colliders when level editing tools aren't active, theoretically. That being said, the performance issues are there even when editing the level, specifically when the level is unpaused.

#

We don't need 3D mesh colliders for actual physics either

#

We use 2D physics and Polygon Colliders for that.

#

The Mesh Colliders are just there as raycast hit targets, so you can click on objects in the level to select them for editing

#

The really weird thing is that, well, should mesh colliders even be considered by the 2D physics system?

jovial wraith
#

why can't you use the polygon colliders for selection?

split solar
#

Maybe. But I thought that only 2D colliders worked with 2D rigid bodies, and that only 3D colliders worked with 3D rigid bodies.

split solar
jovial wraith
split solar
#

so, a level object can be behind another one

split solar
#

Hmmmmm

#

this might actually solve the problem

#

I should risk breaking my NDA more often 😛

#

Thanks y'all!

#

Only concern I have is, that second method seems to be hitting objects in the background first, rather than objects in the foreground

jovial wraith
split solar
#

I'm using Camera.ScreenPointToRay()

#

to generate the ray from the position of the mouse cursor on-screen

jovial wraith
#

🤷‍♂️ I dunno.. play with it

timid dove
#

Using the layer collision matrix

#

What did you use all your layers for? You can probably reclaim some other layers by redesigning something else in the game

dapper eagle
#

Hello, i was wondering if anyone knows a good starting point for bicycle physics / motorcycle physics?
I have had some interest in bicycle physics since it's just a fun thing to do, but don't really have an idea how to get started.
The things i am wondering about is how best to do the wheels for example, wheel colliders don't seem suitable to me.
Are there any resources maybe that talk about implementing such physics in games that are easily applicable in Unity?

split solar
#

Is there an equivalent of RaycastHit.textureCoord but for RaycastHit2D?

split solar
# jovial wraith camera is at z = -10 by default. Are you casting from the correct direction?

There are some scenarios in this game's level editor where we still need to do 3D raycasts. I won't go into detail because NDA. But it's still something I need to do.

So my question now is... for these edge cases, could I theoretically do an initial Physics2D.GetRayIntersection() to find the object I want to edit, and then, when I do, attach a temporary MeshCollider to that one object that's set as "Is Trigger?"

Because then I could do a second raycast to that exact same object- but get all of the extra information you get froma 3D raycast hit.

My question about this is... how expensive is this to do?

jovial wraith
# split solar There are some scenarios in this game's level editor where we still need to do...

No idea. If attaching a new collider is prohibitively expensive, I expect enabling the colliders when needed would be faster than attaching them and I assume disabled colliders have very low overhead. Just doing a 2nd raycast should be fine.

You might need to sync physics after attaching the collider for it to register properly. If you're doing that every frame it's probably bad, but once in a while is likely okay.

split solar
#

I decided on just enabling/disabling them as needed

split solar
#

Is there a way to locate all Rigidbody2Ds that are set to Continuous?

#

my FPS is tanking again and 60% of CPU time is spent on SolveContinuousIslandTask

unique cave
kindred lion
#

really basic problem here

#

but

#

uh

#

ball not bouncing

#

bounciness of material is 1

#

this is my floor

#

nvm

woeful rapids
#

I have an object with a Mesh Collider on it. In my code I have an OnCollisionEnter working correctly for it.

But physics is also being applied for these collisions, which I don't want.

Is Trigger is greyed out on the Mesh Collider as you can see. If I check Convex, then I can check Is Trigger, but then no collisions are registered and OnCollisionEnter is never called.

Basically, does anyone know how to make a Mesh Collider not interact with physics, but register collisions?

kindred lion
#

change it from on collision enter to ontriggerenter

#

because you have the script saying collision it removes the option for is trigger

#

triggers cant collide

woeful rapids
jovial wraith
woeful rapids
timid dove
civic marsh
#

Is this the right place to talk about maths ? (Rotation matrix for example)

viral ginkgo
#

@civic marsh Its fine whats the question

civic marsh
#

Alright, should have asked the question first.
I'm still a beginner in linear algebra and I'd like to know how I could "estimate" this rotation matrix.
It's the Approach #1 : https://stackoverflow.com/a/53559963

viral ginkgo
#

@civic marsh So you want to have this rotation matrix

#

And then you wanna do the check as if the box was axis aligned?

civic marsh
#

Exactly, apply the matrix to the point in order to check if it's in the box

#

as if it's aa

viral ginkgo
#

I think the confusing part here is how to use the rotation matrix to have the point in the cubes local coordinate system

#

R' * p
should be the point in cube space I think

#

Where R' is the inverse of this rotation matrix

#

@civic marsh

civic marsh
#

Isn't multiplying R by p enough ?

viral ginkgo
#

It might be just
R * p yeah

civic marsh
#

Alright, where my problem lies is in finding the rotation matrix

#

I don't know how to get it, the columns are the locals ok, but the rest of it is a mystery to me

viral ginkgo
#

its no big deal

#

its literally like this

#

ill make this simple for you

#

first column is transform.right

#

second is transform.up
third is transform.forward

#

you dont need the a,b,c,d's

#

its literally the local right,up,forward

#

in world space

#

what you get from transform.up,right,forward

civic marsh
#

Alright, what do I fill the rest of the rotation matrix with ?

viral ginkgo
#

oh wait

#

you also gotta scale it with transform scale

#

instead of using transform.right

#

you can use transform.right * transform.scale.x

#

or this:
transform.right * transform.scale.x * 0.5f

#

also do for y and z of course

viral ginkgo
#

3x3

#

what do you mean rest of the matrix?

#

3 vectors already fill the matrix

civic marsh
#

I'll get back to you in a bit, sorry

#

Oh I see I'm dumb, the components of the 3 vectors are placed vertically in the matrix

viral ginkgo
#

yeah

haughty fractal
#

Hey guys, I'm trying to make a robot that uses physics, what I mean is I want it to move but also be physically influenced by hits/movement/damage

So far I have it working great moving forward using

rb.transform.position = Vector3.Lerp(transform.position, transform.position + -transform.right * 0.1f, Time.deltaTime * 2);```

(my model has a wrong transform so ignore the weird transform directions)

What i'm trying to figure out is how to lerp the rotation as well, i've tried stuff like
```cs
rb.transform.rotation = Quaternion.Lerp(rb.transform.rotation, Quaternion.Eueler(rb.transform.rotation.x, rb.transform.rotation.y + 1, rb.transform.rotation.z), time.deltaTime * 2);

And it's just not working great, any advice on physical (rigidbody) rotation or just physical enemy movement in general?

haughty fractal
#

Okay I got some rotation working with this code

rb.transform.rotation = Quaternion.RotateTowards(rb.transform.rotation, 
                Quaternion.Euler(rb.transform.rotation.x, rb.transform.rotation.y + 1, rb.transform.rotation.z), Time.deltaTime * 12);
#

but the issue is it doesn't actually increment the Y value, it just goes to 0, I was expecting it to keep incrementing

jovial wraith
#

also, setting the rotation and position of an object directly like this will break physics on the object. You're overriding any changes the rigidbody might try to make to the object. If that's what you want, that's fine, but since you posted in #⚛️┃physics I'm assuming its not what you were hoping for

haughty fractal
haughty fractal
#

That worked perfectly, @jovial wraith , here's the line specifically

rb.transform.eulerAngles = Vector3.Lerp(rb.transform.eulerAngles, new Vector3(rb.transform.eulerAngles.x, rb.transform.eulerAngles.y + 1, rb.transform.eulerAngles.z), Time.deltaTime * 16);```
Many thanks!
karmic minnow
#

Hey guys! I really need help, I can't advance my project with this feature for like 14 days now, I just can't figure it out. I have to get to know, if there is a specific tagged object between 2 positions (2D)
I tried raycasts, but they dont seem to work the way they are supposed to. I rly need help pls.

timid dove
#

But that's a very weird usage of Lerp/Slerp

haughty fractal
timid dove
#

I don't think Lerp is going to add anything of value here, the way you are using it.

#

It will not create a smoothing effect for example

haughty fractal
#

Ah yeah I see what you're saying, because it's just incrementing itself already

#

Good point!!

vocal steppe
#

Do physics calculations (collisions and triggers) on nested colliders not work when building using the Dedicated Server option?

vocal steppe
#

Essentially what I need to know is why a convex mesh collider wouldn't detect collisions just because there's no camera.

supple sparrow
karmic minnow
#

also if i raycast it with a click, then its ok, but if i want to raycast between 2 points in 2D then i cannot find anything 😦

supple sparrow
#

Hard to help you because you dont know yet what you don't know yet ^^ and we don't see what you don't show ^^

#

Though from what you said I could try a guess : are you sure you're using the 2D variant ? Physics2D.Raycast and not just Physics.Raycast ?

#

That could explain why it works from camera

heady sierra
#

what is Rigidbody.GetRelativePointVelocity(Vector3 relativePoint) ?
I understand GetPointVelocity as this : if the rigidbody only has linear velocity, the function will return the same value as rigidbody.velocity. But if it is rotating, then it will consider angularVelocity as well. In which case a point farther from the centre of mass will have a higher value. But i don't understand what GetRelativePointVelocity. Even in the documention, the explaination isn't clear and the example actually doesn't use GetRelativePointVelocity but instead uses GetPointVelocity(transform.TransformPoint(localPoint)). So i thought they are both same but they are giving different values. Can someone explain with an example what it is.

timid dove
#

basically - you put in a local position, and you get out the local velocity of that position

#

so like for a wheel - if you put Vector3.zero (the center of the wheel) you'll always get 0 out for the relative point velocity

#

but if you put a point on the outside of the wheel you'll get the velocity of that part of the wheel relative to the center - so it'll be a forward velocity at the top of the wheel, negative at the bottom

#

local velocity of a local point

#

I think that's what it does but maybe best to experiment a little to confirm

#

The documentation doesn't really specify if the output velocity is in local or world space

heady sierra
#

ok. that gives me a better idea. Thanks.

karmic minnow
supple sparrow
#

No sorry. Fell free to post here, anybody can help

tough path
#

I'm trying to use Physics.ComputePenetration(...) to create my own custom character controller. The function returns only a boolean for if we collided, a Vector3 for the direction to depenetrate our collider, and a distance to multiply that direction with

#

This works pretty well for discrete collision checks

#

but it comes with the limitation of not returning the position of where we actually collided, which is what I'm trying to figure out

#

Similarly to how, in OnCollisionEnter, you can call collider.GetContacts(0).point to find the point of the collision

#

Thank you in advance

vast pollen
#

Im a little confused about something. I have some models with rigid bodies on them and apply some torque. They don't seem to rotate around their center of mass. When I add a collider and edit it so the center matches the COM it looks like it takes that as the center of mass. However when I set the collider to trigger this effect dissapears and the COM is wrong again. 🤷‍♂️ What is the sensible/correct way to set the COM correctly for rigidbodies?

tawdry forge
#

How can I get the red vector? I want to add force in that direction...

#

I'm trying to add that force to other GameObject, but in the direction of the red arrow...

#

Ok thanks alot @timid dove

main socket
#

Hey could someone help me with this?

I have two capsules with a charactercontroller on each.

#

My problem is that if the two capsules move into eachother one will "slide" above or below

#

how can i stop this from happening?

visual karma
#

i was checking out rigidbody vs collider

#

so what's the point of only having a collider?

inner thistle
#

Read the other answer

timid dove
visual karma
#

thanks!

visual karma
#

how are rigidbody bounds defined?

#

does it just use the union of all the colliders on an object or something?

inner thistle
#

Rigidbodies don't have bounds

timid dove
visual karma
#

oh wow

winter pumice
#

Don't know if this is the right channel but, how would I go about rotating a rigidbody with the x axis of mouse input by using add torque?

jovial wraith
visual karma
#

changing the scale of an object preserves everything on it right? colliders, RBs, etc.?

timid dove
#

Wdym by "preserves"?

visual karma
#

say, if i had a collider/RB on this box

#

and then i dilated it by a factor of 2

#

the collider/RB would go along with the new shape

unique cave
#

Colliders are trying their best to stretch to the new scale but primitive colliders can only change their parameters, the primitive shape will never change. For example, if you scale a sphere collider along one axis, the sphere will grow in radius but you cant get ellipsoid by scaling a sphere collider. If you scale a capsule collider, only the radius and height will change to match the new size.

somber kestrel
#

How can I push rigidbodies with CharacterController? it seems that CharacterController annihilates rigidbody features

#

cannot even push a carrot

#

fine, I have decided to create children object with RB and collider and it seems working

timid dove
#

pick one or the other

somber kestrel
#

no it does not cover the functionality i want from my player

#

not only move through CC but also affect the environment involving physics

#

I said under the picture that I've made a player object both CC and RB and it works fine

timid dove
#

If your RB is kinematic though you will at least not get a complete disaster movement wise

somber kestrel
#

it's cool I didn't know it obviously

#

however I think making a script for pushing objects is little much work to do compared if you simply put RB into a child object

timid dove
#

but not a realistic push impulse

frigid obsidian
#

Has anyone had issues with Physics.Raycast not detecting when an object is removed, the hit data doesn't update. It works fine in Physics.Raycast2D

#

So cast a ray, it detects when the object appears, all good, but when that object disappears.

#

I guess i need a collider on the world edge

#

Thanks, sometimes typing out the problem helps. Thanks for listening

#

Ok, no that didn't work, but the 2D Physics works fine, come on Unity

frigid obsidian
#

Ok, seems the hit data stays until its replaced, different from 2D. So rather than check for any hit data, i'm now looking for certain layers. Works fine

timid dove
frigid obsidian
#

That could be it

timid dove
#

also yes if you are reusing a RaycastHit variable make sure you're not reading stale data

frigid obsidian
#

I'm using a layermask, so when the ray gets filtered out by that, the old data stays. I was looking for a flush ray data method, however, checking the layer of the collision object seems to work, as its no longer in the scene. Weird it works in 2D, regardless. Thanks for the SyncTransform method, it didn't solve it, but a useful thing to know about. Cheers

timid dove
#

The only way that wouldn't happen is if you have some code path where Raycast is not called

#

Now the other possibility is you are not properly checking for whether the raycast hit anything or not

#

you should generally have a structure like:

if (Physics.Raycast(...out RaycastHit hit, ...)) {
  // hit
}
else {
  // miss
}```
#

Which is indeed different from 2D

frigid obsidian
#

I have that, i followed the docs

timid dove
#

"flush ray data" doesn't really make sense

frigid obsidian
#

Right, i was thinking the same, this bug took me by surprise

#

However, if you run a test, that above if statement lets you in when the object is removed from the scene EDIT: my mistake here, without going into it, i was expecting the hit data to be cleared, the if statement does work, but the data doesn't clear

#

Thanks for your replies

rancid shell
#

i am using 2D physics for particle collision, but I need to be able to rotate the particle system in 3D space. if I rotate my system too perpendicular to the x/y plane, collisions will break. Is there some way I can create a localized 2D physics world that I can rotate in 3D space?

#

i want to use 2D physics so that I can use concave triggers to control how a particle behaves in a simulated material. here i'm just having the particles bounce off the collider, but I want to have particles slow down or diffuse through different materials represented by triggers. with 3D physics, i'd need to set up several convex triggers to conform to complex shapes

wary ferry
#

I have an object with a rigidbody where I am setting it's position using transform.position before using AddForce to it's rigidbody in the same frame. For some reason, seemingly randomly, the position wont update before the force is applied, causing the object to stay at it's original location and then moving forward due to the AddForce call. When I instead set the position using rigidbody.position, it works as expected, except I can see the object at it's old location for a split second, I'm assuming this is until the next physics step. When I use both transform.position and rigidbody.position in the same Update loop, it works as intended, moving to the new position and then applying the force. Anyone know why this is happening?

timid dove
#

or do what you did - moving both manually to basically manually sync that one transform -> RB

wary ferry
#

dunno where you guys learn this stuff from

timid dove
#

experience

golden isle
#

I realized the physics chat might be a better place for this... I'm having issues with my player clipping through terrain. I just made a basic terrain with a few hills, and when moving fast the player can clip through them and fall through the earth. I have a rigidbody on my player with Collision Detection set to Continuous, and a capsule collider. The terrain has a Terrain Collider, and I've tried adding a kinematic rigidbody to it with continuous collision detection as well, but the character can still pass through a hill and disappear.

#

I'm moving the player using rigidBody.MovePosition.. movement using addforce felt a little too slip and slide.

unique cave
glossy sable
#

Can anyone confirm or deny whether raycasts (in 2d physics) respect interpolated positions of rigidbodies? In particular, if a raycast shot towards the very corner of a collider on an interpolated rigidbody (using the interpolated position to determine where that corner is) could miss the collider, since the interpolated position of the corner is just slightly in a different position than the non-interpolated position in the physics simulation?
Trying to track down a bug. Stops happening when I turn off interpolation, so that's my best guess.

#

Well, I guess I should have just tried instead of asking. If anyone wants to know, answer is: yes, the raycast can miss if you use the interpolated position

unique cave
#

Afaik interpolation only affects the position of transfrom and the visual appearance but doesnt do anything to physics (position of rb and colliders)

sage apex
#

Hey, does anyone know how to make a prismatic joint ?

karmic minnow
#

Someone help me 1 on 1 with screenshare with 2D raycasts pls 😦 I watched like all tutorials about it 😦

dense pawn
#

does anyone know if it's possible to create a compound collider in unity with trigger colliders instead of regular colliders? cant find anything on google. like this
-- parent (kinematic rigidbody)
-- child (box collider set to trigger)
-- child (box collider set to trigger)
-- child (box collider set to trigger)
documentation only mentions the use case of colliders with isTrigger = false
the problem is that i get multiple on trigger enters/exits, expect to only receive one?

somber kestrel
#

found out that with a mesh collider like this, dents in mesh are not considered, meaning I cannot access cubes inside because they are overlayed with collider of the box. Can it be fixed?

unique cave
somber kestrel
#

yes

unique cave
#

Wut

somber kestrel
#

okey it seems impossible for unity to create dented mesh colliders so I can use various shapes to build my collider afterall

unique cave
frigid obsidian
#

Having some issues with a child model position, it slowly loses sync with the parent position. Has anyone dealt with this issue? I'm thinking i maybe need to run a worldspace check to align them again, its maybe down to the 32 bit floats for the position running out of decimals, so i'm getting quantisation errors, not sure

jovial wraith
frigid obsidian
#

there is nothing on the child, just an animator

#

It goes - player -> model -> mixamo

The player has the Rigidboby + Box Collider and the movement script.

The model is just an empty Gameobject.

The Mixamo has the Animator on it

#

I think it has something todo with the Mixamo animation tbh, its slowly losing sync. Pain in the ass

kindred patrol
#

when it comes to putting coliders on my hands which one do i chose

frigid obsidian
#

Ok, solved my issues by getting rid of all children, and packing everything onto one game object. Its way messier, but things stay in sync now. Not sure how larger projects get built

kindred patrol
#

I have been working on the physisc following a video by valem tutorials HE has provided me a package that has these great models the issue is if you look in the bottom right the left hand prescense is broken this means i cant use any animations for the left hand any help

lucid mortar
#

Newbie question regarding character joints. How to configure the swing axis? I mean, what does it mean exactly? if my character is in T Pose facing Z axis and I want to configure the left elbow joint which is aligned with X axis in T pose, what vector3 value should I use for the left elbow?
Does the swing means which axis will be used as rotation? Which means I'd need 0,1,0 since it'll rotate around Y axis ?

viral ginkgo
#

It means you are rotating around that axis

#

Thats the save way with torque and angular velocity vectors as well

vital loom
#

i also had a question about character joints! well, maybe character joints? im making a game with a frog character and procedural climbing. I wanted a add a tounge that had a active ragdoll look, but character joints were giving me a headache

#

is there a good way to get an elastic look with physics objects

zealous ermine
kindred patrol
#

Suggestions for making my ball move more realisticly

unique cave
kindred patrol
unique cave
kindred patrol
kind pilot
#

how do i make active ragdolls?

kind pilot
#

ok so how do i fix this

lucid mortar
gloomy blade
#

Hey guys, new to unity here. I'm trying to do pixel perfect collisions for a pixel-art game using Kinematic Rigid Bodies. I'm having an issue where the purple-border square sprite there is colliding with the tilemap, despite them both having what I assume are perfectly configured Box Colliders of 32 pixels of length (or the tilemap equivalent of that). Why exactly is this? Should I tackle the colliders from a different approach for pixel perfect collisions?

gloomy blade
#

Nevermind, figured out it's the default contact offset. I'm gonna have to make the colliders' length a pixel thinner or each side since I can't set the offset to 0

karmic minnow
#

Can someone help me set up a 2D raycast and scan if an object is there please? 😦

unique cave
split briar
#

I can't wrap my head around raycasts. Why doesn't this work:
```csharp
var hit = Physics2D.Raycast(
templatePrefab.transform.position,
transform.TransformDirection(Vector2.down),
Mathf.Infinity,
LayerMask.NameToLayer("Ally")
);

                if (hit.collider == null) ...

I'm trying to check if there is a GO with the Ally layer underneath the templatePrefab GameObject. The Ally and template GameObjects have a collider and RigidBody
unique cave
split briar
#

Cool, thanks ^^ I'll try

gloomy blade
#

Does Rigidbody2D.Cast put the RaycastHit2Ds in the results in any particular order? I would like to solve collision according to the first hit along the length of the ray, wondering if i have to do that sorting process myself

karmic minnow
#

I know that even tho I tried to raycast, I even tried to see it with DebugRaycast but I just couldnt find where it was raycasting from and to

#

it raycasted on a completely other position

#

I already got the Positions (from & to) for the raycast, It works when i have to spawn something, but when i tried to raycast from those positions, it just puts it on a completely bad position

unique cave
#

You should show the code, its impossible to help if thats all we know

timid dove
gloomy blade
#

Thanks 👍

#

It seems to naturally order them by fraction but as it's undocumented I guess it could be purely coincidental

rare juniper
#

I'm a bit confused as to whether or not I should have a kinematic rigidbody on my prefab, or if I should remove the rigidbody component all together, and just update the objects transform.position. I'm rendering thousands of objects in game which are based on real-world objects (position data obtained through an API), and thus I don't need the Unity physics engine to move these objects. However, I do need colliders on these objects in order to detect user interaction with the objects. When these objects move (based on the updated position from the API), should I update the position by doing transform.position = {new position}? Or should I attach a kinematic rigid body and use rigidbody.movePosition? Thanks!

tawdry dawn
#

Hello, I have a problem with physics. I've made a simple car model and tried to get some good and somewhat realistic physics for it, yet after I added the rigidbody, collider for the car itself and the wheel colliders, i've noticed that the car behaves rather strangely (as shown in the picture). To clarify, it's standing on a perfectly flat plane, and without even moving it, it just sways to one side or another. I'm not sure, but I think there's just something about physics I don't know. Any ideas why does this happen? Thanks in advance
Edit: I think I've found an answer, or at least a clue. It turns out that lowering the center of mass actually causes problems like this (the center of mass is moved only on the Y axis, so it's not off to the side).

jovial wraith
unique cave
iron mulch
#

I'm having a really weird issue with a ragdoll I made via the ragdoll wizard. Whenever the enemy dies, it spawns a ragdoll by instantiating the enemy model (which is just a ragdoll with the animator component turned on) and disabling the animator component on the ragdoll, as well as disabling the enemy model as well. However, it seems like over time, the enemy model's ragdoll becomes more inaccurate? It's hard to explain, so here's a video of it, and the relevant portions of code. Does anyone know if there's something wrong with this method of creating ragdolls?

if (curHealth <= 0 && isDead == false)
        {
            GameObject ragdoll = Instantiate(model, new Vector3(transform.position.x, transform.position.y, transform.position.z), transform.rotation);
            ragdoll.GetComponent<Animator>().enabled = false;
            ragdoll.AddComponent<SelfDelete>();
            model.SetActive(false);
            StartCoroutine("respawn");
        }

...

IEnumerator respawn()
    {
        yield return new WaitForSeconds(respawnTime);
        model.SetActive(true);
    }
#

(Oddly enough, it seemed to work when I wasn't creating copies of the model, but I didn't exactly stress test that approach much)

unique cave
# unique cave Moving static rigidbodies was issue prior to unity 5 😂, thats ”fixed” ages ago....

@jovial wraith And by ”fixing” I mean its changed to work in a way you gain less by using static colliders but you dont get huge performance inpact every time you move them. Static colliders werent never really broken but people just didnt know how to use them properly and therefore caused a lot of performance issues, because of that unity decided to make this change to unity 5 and later versions

gloomy blade
#

Anyone know what's wrong with my ContactFilter2D? It's filtering out the slope collision, and I made sure the layer name is correct. Am I not setting the object's layer correct or something? I'm just using the dropdown from the editor on the slope object.

ContactFilter2D filter = new ContactFilter2D();
mask = LayerMask.NameToLayer("Slope");
filter.SetLayerMask(mask);
int total = slopeCollider.Cast(frameVelocity, filter, castResults, frameVelocity.magnitude);
wet quiver
#

Hi. Could somebody help with veeeeery newbie basic stuff ? i've got a thing which is supposed to be a character and another supposed to be a plateform. The first one has a rigidbody 2d and the other one a box collider and although they're on the same layer order they don't collide.

#

Thanks

jovial wraith
jovial wraith
jovial wraith
high verge
#

does anyone know how to do layer collisions but in 2d?

jovial wraith
high verge
#

oh

#

is not working

#

nvm

jovial wraith
high verge
#

nothing i just figured it out

wet quiver
#

Ok it's resolved and that was silly the one with the rigid body didnthave any collider

#

as a game grows do all colldier and bodies make performances problems ?

#

is there a way to use one collider for multiple objects for example

#

with a prefab or something ?

timid dove
#

Also Yes it's GetMask

unique cave
# jovial wraith ah, I stand corrected. Thanks for the info! My comment about raycasts was becaus...

The reason its now faster is because (if I understood correctly) dynamic objects shares the same aabb tree with static objects (or atleast static uses similiar structure with dynamic) and moving static objects doesnt automatically trigger expensive aabb tree rebuild. It seems nowadays Physics.autoSyncTransforms is set false by default and shouldnt be set true which I understand means that when you move static object, the colliders and rigidbody will not update their positions until beginning of the next physics update. So I think you still need to call Physics.SyncTransforms if you want to use raycasts in update method before the next physics step.

gloomy blade
stuck bay
#

Been trying to make a 3d snake skeleton out of joints and spheres like in Snake Pass. I can kind of get the slither effect to work, but it's a far cry from working the way I want it to haha

smoky hollow
#

I have a Rigidbody gameobject with 2 hinges. One hinge connects to the chain link I made perfectly while the other separates the anchor and the connected anchor. Any clue how I can make sure they never separate?

smoky hollow
#

Fixed it

drifting sleet
#

does anyone have experience improving performance of vehicles / wheel colliders?

gilded sparrow
#

If i make my whole stage with mesh collider of the shape like these modular rocks, is it feasible?

Are mesh cols of these size (and just around ~300 vertx) as stage feasible, or definitely a no go and gotta rebuild it with primitives cols?

unique cave
molten lava
#

Question, how do i prevent my tree's trunk from swaying?

tulip goblet
#

Hello doghi I hope I'm asking in proper channel, my question is: if one material has friction combine "average" and the other one has friction combine selected "multiply" which is being used when two objects are rubbing each other?

visual karma
#

is using transform.translate bad for movement?

#

i feel like it'll mess up

#

with the colliders & whatnot

#

might cause a bit of clipping?

unborn geyser
#

which physics material you are using

tulip goblet
#

What do you use then?

unborn geyser
tulip goblet
stuck bay
#

how do i

#

make collisions

#

without rigid body

#

rigid body just messes up everything in my movement system

unique cave
visual karma
#

yeah that's what i thought

unique cave
#

Rigidbody.position isnt much better tho. .velocity and .AddForce will most likely give better results

visual karma
#

yeah

#

so changing the velocity

#

is ok?

bleak umbra
# visual karma is ok?

if you use a rigidbody only to have it move by itself after you set its velocity, you are often better off using a kinematic rigidbody and move it with Rigidbody.MovePosition() in each fixed update directly. An active (non-kinematic) rigidbody makes only sense if you actually want force simulation.

visual karma
#

so i'm just doing a simple double jump

#

AddForce makes it so that the double jump is often much less smaller than the first jump

#

so i just changed the y velocity every jump

bleak umbra
#

yes, you are basically fighting the physics simulation, which you can do if you know exactly how that works and keep it minimally invasive, else you are setting yourself up for a lot of annoying edge cases and lots of tweaking work

#

the alternative is to make the character move with a custom motion function that can behave exactly as you like and disregard any physically correct movement.

#

usually in a game you do not need or want physically correct movement unless it is a simulation game

visual karma
bleak umbra
visual karma
#

custom motion function
what would this manipulate?

#

it would seem really nasty to get gravity and that stuff in with the jumping & horizontal movement & all that?

visual karma
#

that just seems to be a fancier version of transform.translate

bleak umbra
#

to make a kinematic controller you do something like this (oversimplified):


Vector3 _transientVelocity;
bool _isGrounded;

void FixedUpdate() {
    _isGrounded = Physics.Raycast(transform.position + Vector3.up * 0.1f, Vector3.down, 0.2f); 
    
    if (!_isGrounded)
        _transientVelocity += Vector.down * 9.81f;

    _transientVelocity += movementAction.ReadValue<Vector2>().ToXZ();
   
    rigidbody.MovePosition(transform.position + _transientVelocity * Time.fixedDeltatime);
}
visual karma
#

oh dear god

bleak umbra
#

but since controllers are more complicated you'd split that up into multiple updates, maybe focusing on input, rotation, velocity and post processing separately and then just update the rigidbody with the result. in each step you can do completely custom behaviour

visual karma
#

ah ic, tysm!

visual karma
bleak umbra
#

the ease by which you can make a character jump or a cube move with forces belies the complexity involved in making it actually achieve decent game feel. Either way you pick (forces or kinematic) will be difficult in its own way.

dreamy pollen
#

Anyone use the Contact Mods API?

#

I'm having some issues with fast moving continuous dynamic rigidbodies getting stuck on colliders that are set to ignore the contact pair and I'm wondering if its a bug

mossy iron
#

Why isn't my CharacterController detecting collisions with my Tilemap?

#

They're both on the same Z access.

strange raven
#

the two physics types can't interact with each other

mossy iron
#

Oh man.

#

Thank you.

#

I ended up just disabling collisions on character controller

#

But that's good to know

#

Is it pretty much recommended to not bother with the character controller for 2D? The only thing I am really using it for so far is Move. I suppose I can just update the Transform instead. I don't really want to move by applying forces