#⚛️┃physics

1 messages · Page 82 of 1

unique cave
#

but it doesn't (as mentioned, I tried that myself some time ago). continuous is good for fast moving objects but is still tunneling on some cases like this

versed shadow
#

Fast moving objects is kind of a misnomer

#

It's just about your frame rate

#

I don't know why continuous doesn't prevent tunnelling in this case, it should

unique cave
#

well I'm not sure what you're doing but what I did was to have the first loop fixed in space and others can swing freely. not even continous collision detection can guarantee objects not going thru each other when stretched from both sides with large forces.

versed shadow
#

Since of course the links in a long chain will rotate that might be what's causing the issue

unique cave
#

I don't think so...

#

let me experiment with this

versed shadow
#

Maybe one day we'll have quantum computers and collisions can be done a lot more efficiently

#

Then we can use more sophisticated algorithms

unique cave
#

yep, it has nothing to do with rotations

#

afaik two objects should never go thru each other (with ccd) but if there's third object and the object in the middle is pulled in both direction, you're in troubles. lemme show you

versed shadow
#

But I'm almost certain if you only have 2 links and they aren't rotating you can pull them with whatever force you like and they won't tunnel

unique cave
#

that should be the case, but I'm not sure if that's still guaranteed. there may still be some edge cases when using compound colliders

versed shadow
#

For performance reasons it doesn't really make sense not to use joints anyway

unique cave
versed shadow
#

That's very weird tbh

#

I guess if the small sphere is fixed and the plane is removed the issue isn't still there

#

If it is I just think the CCD algorithm sucks XD

unique cave
#

it is but on the other hand, you very rarely need that type of collision on real game application. game engine can't have "perfect" physics engine because it has to be very optimized

unique cave
versed shadow
#

What a shame

#

Oh well in the future these problems will probably be gone

unique cave
supple sparrow
#

Nice !

versed shadow
unique cave
#

I believe that's not going to give any more realism on regular games with reasonable amount of forces applied from multiple directions. With more computation power you could obviously use some Two Minute Papers level physics on games but that's whole another story

gentle chasm
#

ok so if u freeze the y pos and have it bounce it doesnt bounce
why is that?

#

like a sprite moving across the grid

neat coral
#

what's the problem?

glass kettle
#

Rigidbody Interpolate in Unity 2022

neat coral
glass kettle
#

201* < 2019, 2020, 2021 - Correct
2022.* - Incorrect

gentle chasm
#

When it hits something

stuck bay
#

there is something that i discordverederd

#

is that interpolation can have with calculations involving the coordinates of a moving rigid body

#

it seems that without interpolation, the calculations are based on the coordinates of the body in the last physics timestep

#

however with interpolation the calculations are based on an estimation if the rigidbidy within its current and next step

#

At the time between the current and next timestep that the calculation takes place

#

so its more accurate

unique cave
# stuck bay Have you tried interpolation

No. Interpolation only affects visuals, not physics. Physics are exactly same with and without interpolation but interpolation just smooths the look of movement so it’s not that jittery

stuck bay
#

i rly need an explanation sorry i didnt mean to tie that up to your question

#

this rly confuses me

unique cave
#

Now this confused me too 😂. I may be wrong too but that’s how I have been understanding it

unique cave
#

You do that in update?

stuck bay
#

It seems to rely on the interpolation of the rigidbidy

#

which seems stupid, i understand why you thought fixedupdate should do that and i thought that aswell, but it doesnt

unique cave
#

I didn’t mean to say it only affects ”visuals” but I wanted to say it doesn’t affect physics. Actual position and rotation of transform/rigidbody (not sure which or both) gets interpolated but collisions are still calculated with the same fixed rate

prime flower
#

“rigidbody.position” will be the true position of the physics body while “transform.position” will be the position of the “fake visual”

stuck bay
#

im pretty sure my program uses the transform of the visual and not the rigidbody, is that the issue?

#

of course

#

it maks sense now thank yoy

timid dove
#

if you're making gameplay/physical/logic decisions based on it, then yes

prime flower
#

I think you might be dealing with a large physics timestep, and you are trying to solve inaccuracies there using interpolation instead of a smaller time step

#

Can you tell us what you mean by “the calculations lag in fixedupdate”?

stuck bay
#

the rigid body is rotating constantly with the angular velocity set to a constant value by code

stuck bay
#

so it has 2 rotations at t=0 and t=1
It gives the rotation at t=0 which is outdated because the rigidbody is already at t=1

prime flower
#

It’s not outdated in terms of the physics engine tho

stuck bay
#

no

prime flower
#

It’s outdated in terms of visual frames

stuck bay
#

ye

prime flower
#

There’s a key distinction there

#

Is the vector your trying to calculate going to be used for visuals, or other physics stuff?

stuck bay
prime flower
#

Then what you are seeing isn’t outdated and it’s the value you want to be using tbh

#

If you are using transform.position or rotation for a physics calculation with interpolation turned on, you’re gonna run into problems

#

Try switching to rigibody.position and I bet you’ll see that the calculation is laggy or behind again, even in Update()

#

@stuck bay what’s your physics timestep set to?

stuck bay
#

i havent checked because i dont want to change the timestep bc im having issues with one calculation, kinda feels like im giving up

prime flower
#

Are you running at 60fps or 144fps?

#

Because at default timestep, that means at 144fps you’ll be running physics 1 time for every 3 frames

#

Physics vs frame mismatches are more noticeable at higher FPS

stuck bay
prime flower
#

60hz or 144hz

stuck bay
#

idk

prime flower
#

A fps counter is always nice for debugging

#

But either way

stuck bay
#

get the normal of the slope by passing a raycast on it then project onto the plane with the normal
https://youtu.be/cTIAhwlvW9M this video has a ni xplanaion if it

The third part of my Rigidbody FPS Controller series. In this video, I covered slope handling, fixing the weird jitter, and improving the ground detection. In the next one, we will start working on the wallrunning *yay. Make sure to subscribe so you don't miss it :)

Discord Server Invite: https://discord.gg/6ASySnPVXB
GitHub Repository: https:/...

▶ Play video
split wedge
#

I have an oddly specific question.

#

I'm doing bullet trajectories manually, as to avoid having to do massive amount of calculations per frame with the Rigidbody component.

#

However, the bullets only inconsistently detect collision.

#

Is there a way to use the Rigidbody continuous dynamic or speculative without just using Rigidbody physics?

#

Because I'm going to have enough bullets that Rigidbody physics calculations won't be viable.

#

The relevant part of my physics sim code is as follows:

#
    {
        if(!isInitialized)
        {
            return;
        }

        if(startTime < 0)
        {
            startTime = Time.time;
        }

        RaycastHit hit;

        float currentTime = Time.time - startTime;
        float nextTime = currentTime + Time.fixedDeltaTime;

        Vector3 currentPoint = FindPointOnParabola(currentTime);
        Vector3 nextPoint = FindPointOnParabola(nextTime);

        if(CastRayBetweenPoints(currentPoint, nextPoint, out hit))
        {
            Destroy(gameObject);
            Debug.Log("Hit object: " + hit.transform.name);
        }
    }

    private void Update()
    {
        if(!isInitialized || startTime < 0)
        {
            return;
        }

        float currentTime = Time.time - startTime;
        Vector3 currentPoint = FindPointOnParabola(currentTime);
        transform.position = currentPoint;
    }```
prime flower
#

or are you racasting on top of relying on OnCollisionEnter?

#

or OnTriggerEnter

split wedge
#

In this case, I generate points according to a physics formula, and move the bullet from point to point, creating a nice, good-enough looking arc trajectory

#

And the bullet has a box collider on it

prime flower
#

idk why i can't type a code block with tildes anymore

split wedge
#

And the collision is assisted by casting a ray from current point to last point

#

to see if it hit anything

prime flower
#

yeah so if you're raycasting, isn't that skipping any sort of collision detection completely?

#

I.E raycasting can't be discrete or continuous, it's just raycasting.

split wedge
#

The weird part is how inconsistently my collision works

#

Sometimes it will properly detect floors and walls

timid dove
#

in theory what you have should work pretty consistently

#

but

#

I'd like to see the rest of the code

prime flower
#

I agree

#

CastRayBetweenPoints

#

mainly

split wedge
#

alright gimme a sec

#
    {
        return Physics.Raycast(startPoint, endPoint, out hit, (endPoint - startPoint).magnitude);
    }```
timid dove
#

and also there's a caveat with raycasting - it doesn't detect objects that the ray starts in

prime flower
#

if you're bullet is already inside of the object

timid dove
#

You're using it like LineCast

#

you should just use LineCast if you want to do it this way

prime flower
#

Wow didn't even know about that one cool

timid dove
#
return Physics.Linecast(startPoint, endPoint, out hit);```
#

Linecast takes two positions (like you have)
Raycast needs a position, a direction, and a distance

#

you are improperly providing a position as the direction parameter

#

that probably explains most of your issue

prime flower
#

CastRayBetweenPoints is his own function though so we're not sure if he's already accounting for that

timid dove
#

?

prime flower
#

is it not?

timid dove
#

it's doing a Raycast, improperly

prime flower
#

lmfao whoops

#

well he was on the right track

#

direction should just be (endPoint - startPoint)

split wedge
#

welp apparently that was the issue
got bad advice for that a while back
did about 50 attempts, with perfect collision detection

prime flower
#

@split wedge basically you were raycasting in random directions lol

split wedge
#

Still got a lot to learn with proper raycasting still lol

#

seriously this problem has plagued this project for a long time thanks

prime flower
#

hey you fixed your code and learned how to replace some of it with a cool built in function!

split wedge
#

always nice to not have to reinvent the wheel

stuck bay
# prime flower It’s outdated in terms of visual frames

idk if you can see this but the script does in fact reference the visual frames as you guessed correctly (Transform gridTransform - a declaration of the visual transformation of the object with the rigidbody component and not the rigidbody itself)

#

i just thought it would be more efficient because i only wanted to reference the transform attributes of the rigidbody
But for that they would need to have equal transforms

#

which is possible for an rigidbody of course only if it is synchronized with the object’s visual frames, which is what Interpolation or increasing the physics steps does

stuck bay
#

anyone know how to make the physics of this game better?

#

Download the source code by clicking on the link below:
https://code-projects.org/piggy-zombie-shooting-game-in-unity-engine-with-source-code/
[For educational purposes only]

Become our member:
https://www.youtube.com/channel/UCTcaqNZBMBrrtEXHxPne2bQ/join

📱Download our app from Play Store📲:
http://bit.ly/scpapps

Subscribe To "Source code Pr...

▶ Play video
stuck bay
#

can anyone tell me why the friction's not working

neat coral
#

you are trying to make your character move using the friction of their feet?

#

sounds like a very bad idea

timid dove
stuck bay
timid dove
stuck bay
stuck bay
timid dove
#

they just kinda teleport the stuff around

#

and in that case - well read the caveats in the documentatioin

#

it's not gonna move the guy around the way you want

stuck bay
#

i see

stuck bay
timid dove
#

it only works with Rigidbodies

#

in the first place

stuck bay
#

what if i apply force to the legs, should work?

timid dove
#

and there needs to be actual physical rigidbody motion for it to do anything

#

if you apply a force to a non-kinematic rigidbody, it will accelerate, sure

stuck bay
#

um okay, i'll try smthn tnx

prime flower
#

Physics and animations don’t mix well

#

I work on a lot of physics focused games and normally I have to start with physics and then lay animations on top of that

#

Instead of starting with animations and relying on root motion

sage ice
#

Im having an issue with mesh colliders not colliding but box and capsule colliders are. I'm not sure how to fix this (all the colliders are set to convex btw)

#

Might someone be able to help

stuck bay
#

this is what the working example uses to access the rigidbody transform component

#
gridTransform = other.transform;
#

and this is how the not workng example references it

#
shipTransform = other.GetComponent<Transform>();
#

i changed it to shipTransform = other.transform; however im still experiencing the same problem

#

what i dont understand is why this method works for one script but not another

stuck bay
#

its a rotation offset
visible at higher speeds

#

its because its parenting after the parent gets a non-zero rotation offset
which is a script execution order issue

stuck bay
#

the other setup doesnt have that issue bc its ordered in-script
ig the issue just wasnt visible with less extreme angular velocity

twin nebula
#

So I've made an active ragdoll balance and play walking animations and stuff (with AddForces and a bit of maths). My method of moving the character around and to balance it is to have an invisible sphere underneath it that rolls around and stuff but the issue is whenever I move, since my player's hips are attached to the ball by a spring joint he kinda just rolls with the ball. Is there a way I can make the hips stay connected but not rotate with the ball?

#

I'm rotating the ball with AddTorque

haughty scaffold
#

hi, should i update an object's velocity in fixedupdate or update?

#

im currently running this code in fixedupdate, would this object accelerate at the same speed on 144hz vs 60hz?

unique cave
haughty scaffold
#

got it

#

what should i keep my timestep to? i think i set it to 1/90

unique cave
#

The default of 1/50 is usually pretty good. Interpolation takes care of the little jittering

timber pelican
#

is there a velocity equivalent of transform.forward?

#

i'm trying to apply velocity along forward vector

unique cave
timber pelican
#

yeah didnt realize transform.forward was a vector3

#

thanks

prime flower
#

I feel like 60/120hz physics are way more common in games than 50hz

light hound
#

greetings. I have some small dice. 0.004 mass, and 15 mm in unity. When I throw them, when they land and stop, they like to continue to slowly rotate around the y-axis even though they should be all rights not be moving anymore. I have dynamic friction set to 1.

#

why do they keep rotating?

unique cave
light hound
unique cave
light hound
#

hmm. these dice are using mesh colliders. i wonder if switching to box colliders would help

#

oh weird. i would think primitives would get better results than mesh

unique cave
#

in this case I have heard mesh collider is better than primitives. especially two primitive colliders with large size difference produces some jittering problems

#

id probably try box for the dice and mesh for the table

light hound
#

tried changing them both around. mesh, box, vice versa. same issue. i may just get y delta pos, and when its not moving in y, set all velocity to 0

sage ice
sage ice
#

nvm fixed it

wicked phoenix
#

Trying to create some ragdolls on this model. These ranges mean the arm should be able to swing forward and side to side, right?

young jolt
#

Not sure if this is the right channel, but does anyone know why this happens, I just added ragdolls and they just kinda float away, Use Gravity is checked on the rigid body

unreal linden
timber pelican
#

does Rigidbody have a method to move an object over one frame only, while also checking for collisions?

my issue is that Rigidbody.velocity and .movePosition rely on the object's drag coefficient, so the object's movement is spread across multiple frames.
i'd rather have it move on one frame only. So far, I only know of Transform.Translate, but that causes collision jitter

stuck bay
#

hello, does anyone have knowledge about wheel colliders not colliding. cant rotate as have realised. but once aligning the wheels with the colliders, not long after. they rotate another direction... does anyone know how to fix this issue? or any advice

viral ginkgo
#

@timber pelican maybe you can do boxcasting or spherecasting to solve your problems

#

you'd box/sphere cast and move the shape afterwards

swift egret
#

question: if i have a 2d scene with a bunch of objects forming a "wall" like the tree sprites do here, is having every one of them have their own collider and rigidbody (like the single selected tree sprite where the bird is sitting would have) hell for the performance or does it not matter

#

furthermore how much more intensive are polygon colliders compared to the given 2d collider shapes (rectangle, circle, capsule etc)

neat coral
#

you can probably approximate the bird tree with a rect

timid dove
#

it does not care about drag at all

timber pelican
# timid dove it does not care about drag at all

Maybe, but I still noticed the movement on the object was still spread over multiple frames. That's an issue for me because I need to sync position of the object to other players, but any position data I send to others is already old data because the object continues to move on the next frame on the server.

timid dove
#

MovePosition abides by interpolation settings on the Rigidbody

#

but the movement happens over exactly one physics frame

timber pelican
#

Ok, I'll try it again. My rigidbody had no interp on, so I'll see what happens if I change it.

timid dove
#

there's a lot of factors at play

timber pelican
#

I debug.logged the position data sent on the server and received by the client, and both were the same. Changing movement to transform.translate did not have movement discrepancies, so I don't think it's that. Both are on local computer for now, so shouold be very very little delay

timber pelican
timid dove
timber pelican
#

i read Transform.position

timid dove
#

should generally be reading the RB position, as that won't be subject to any interpolation from any sources.

prime flower
#

the hands are almost all IK + hand poses lol

silk sun
#

Hey I have a problem, my object stops to bounce if the velocity is low, how can I fix it?

shell night
#

i don't get how angular velocity works. it says it's radians/s, yet a value of ~157.104 results in 1 revolution/second !?

#

am i missing something obvious?

neat coral
#

oh no

#

the opposite

#

reduce friction

silk sun
#

yes yes someone helped me already. thank you

jovial wraith
# shell night i don't get how angular velocity works. it says it's radians/s, yet a value of ~...

that could be an aliasing problem. 157 radians/sec is ~25 rotations per second, which happens to line up quite closely with 0.5 rotation per fixed update. So it might be doing almost a full rotation every 2 fixed updates and you only see the small deviations.

Same issue as this video shows: https://www.youtube.com/watch?v=uENITui5_jU

shell night
#

once i fixed that, the values started to appear sensibly

jovial wraith
shell night
split wedge
#

hey uh weird question
is it normal for objects with rigidbodies to fall even with no gravity?

shell night
split wedge
#

apparently restarting unity fixed the physics weirdly enough

prime flower
#

I have weird shit like that happen to me all the time

#

where physics material all of a sudden lose all friction lol

#

until I restart the editor.

#

Compiled builds are always fine though

fair oyster
#

How can i create IK

#

Using blender

#

For Unity 2020.1 LTS

turbid geyser
#

I assume this is a beginner question. I'm getting familiar with Rigidbody Physics and am having a challenge that I'm having trouble researching. I assume the right person will just know that answer 🙂

I have two player controlled characters. When one is hit I apply force to their RigidBody (dynamic body type). When a player moves I call MovePosition in order for there to not be a feeling of velocity when moving.

At this point in time I'm not preventing movement during a push and what ends up happening is the movement removes all of the velocity from the push. For example if I'm pushed to the right while the player is running up I'd like the character to continue progressing up but be pushed right simultaneously, allowing the pushed player to fight against their velocity of the push if they so choose.

Any help would be appreciated

prime flower
twin nebula
#

Is there anyway I could get my Rigidbody to constantly stay up with a torque? What I have now is a character standing on its legs with target rotation but I don't think there's a way for me to keep my character upright with target rotation without having it always point in one direction. Correct me if I'm wrong

prime flower
#

If you aren't moving an object purely with forces (velocity), you won't be able to achieve true physics responses

#

MovePosition is a function that in essence teleports the object, and any collisions that happens in between will not be treated with actual collision responses you expect.

turbid geyser
#

Hm... Okay. Sounds like I need to design around it then. Either prevent movement during push or use velocity for movement.

#

Thank you for your insight

twin nebula
#

Ok so scrap what I said

#

Is there any way to only control the X and Z angular drives?

wary roost
#

I am trying to set up collisions between the player (has a box collider + a kinematic rigidbody) and a tree (has a box collider), but I just cannot work it out. I want the player to simply stop moving when reaching a tree 🌲

I am using 2d sprites in a 3d world, so I cannot add gravity to them, but I can freeze their position*. Is there a way to fix this? Tried so many things but got nowhere so far

timid dove
#

The Renderer is not relevant to how it moves

#

Is there a reason you want to use a kinematic body?

#

If you're using a kinematic body you'll need to do all the collision detection yourself with e.g. BoxCasts

wary roost
#

and if gravity is involved the object will either fall to the ground, or flies away if I disable it (since all the sprites are 60 degrees rotated on the X axis)

timid dove
#

Here's what a kinematic body won't do:
-collide with anything or be stopped by any obstacles.

hard valley
#

why does my wheel collider not collide

#

and no, it isn't rotated

#

and it is in a seperate child object under my car

mortal venture
#

I have a projectile that moves 350 meters per second, and i need to know if it collides with anything by Physics.OverlapSphereNonAlloc or Physics.OverlapSphere, my projectile is supposed to penetrate through some objects, and that's why i use overlap sphere to gather information about what it hit, and if it is penetrable, but OverlapSphereNonAlloc and OverlapSphere doesn't work, and i think its because of the speed the projectile is going, can anyone help me fix it, or have any better idea to implement penetration?

lapis plaza
#

@mortal venture there probably isn't good reason to keep that physics simulated rigidbody in the first place, just sweep it

mortal venture
lapis plaza
#

oh I thought you were using RB already and that was causing your issues

#

but yeah, you could just sweep test the hits

mortal venture
hard valley
#

why does my wheel collider not collide

#

With mesh colliders

#

(Non convex)

carmine basin
#

Is there a way to set the linear limit of a configurable joint in script?

#

its giving me this error

#

"Cannot modify the return value"

#

I want to set it to my blade's stab depth but the IDE is telling me that I can't because even though it has the whole {get; set} thing, it just isn't doing it

#

my current workaround is creating a new SoftJointLimit, assigning stabDepth to that and then assigning the new SJL to the joint

#

which seems to do it

carmine basin
#

I've got a solution now

prime flower
peak cloak
#

I'm making a car racing game with the wheel collider and it was working but once I added the mesh when it touches the ground is starts shaking violently how can I fix that

hard valley
#

same but my collider does not collide at all

amber bay
#

with a floating object, I am applying a force of X to the rigidbody. If I double the mass, will I have to apply a force of 2X to get the same movement

timid dove
#

assuming you are using ForceMode.Force or ForceMode.Impulse

#

There are mass-independent force modes too - Acceleration and VelocityChange

amber bay
#

ok thanks

slate lily
#

Iamma explain the prob
The player is hovering at height of 0.25
And the player Is an overlapped box with penetration vector and velocity projection vector that minimise the velocity if your touching wall so u dont clip into it the offset I mentioned above messes up the projection on the y axis so idk how to fix that

wheat thorn
#

How can I lock my player to a chain(using hinge joints)?

timber pelican
#

is there a way to check if two object's colliders are intersecting, externally from objects?

so imagine 3 hierarchy objects: observer, box1,box2.

can I as Observer detect if box1 and box2 intersect?

kind pilot
#

hello unity folks, i made a car controller, followed this tutorial https://www.youtube.com/watch?v=Z4HA8zJhGEk
but why don't my car move?

[UPDATE] If you are looking for the breaking bugfix check the description after expanding it!

Let’s learn how to create a car controller in Unity. We will get to know Unity’s wheel collider component and use it to move a car. We will also create a simple camera script that will follow the car.

[BREAKING BUGFIX!!]
There is a bug in the HandleMo...

▶ Play video
#

oh apparently inputs

#

are the issue

peak cloak
hard valley
peak cloak
eager dove
#

if my 2d character falls a long ways it kinda pancakes, it seems its rotating on a 3d plane but it dosent show any signs of doing so, please help

stuck bay
#

Hey

#

My mesh isn't colliding with the cube

#

Did I forget something?

carmine basin
#

@stuck bay does your cube have a collider too?

stuck bay
#

yeah

carmine basin
#

huh

stuck bay
#

this is from the second picture

carmine basin
#

are they on layers that don't collide with each other?

stuck bay
#

I haven't set any layers

#

They are both on default

carmine basin
#

oh

#

hang on

#

your mesh collider and mesh filter don't have a mesh assigned

stuck bay
#

?

carmine basin
#

oh

#

hm

#

perhaps not that hten

stuck bay
#

I think it's the correct one

carmine basin
#

is your cube spawning inside the mesh collider?

stuck bay
#

I don't think so

#

I just added a new cube

carmine basin
#

im honestly not sure what's going on here

stuck bay
#

Me neither

#

Is there anything weird going on with the code?

carmine basin
#

I dont think so but i dont really know about mesh generation. Could it be that you need to bake the mesh on the collider?

stuck bay
#

How would I do that?

carmine basin
#

maybe not then, Mesh and meshfilter dont appear to have a bake method

#

damb

#

im honestly not sure

stuck bay
#

I tried asking in beginner code and someone told me it's not a code question and to ask in #⚛️┃physics

#

burh

#

Thanks for trying to help me though

#

Mr goose

#

I appreciate it

prime flower
stuck bay
#

Unity does it for me

prime flower
#

And if you use a mesh collider without creating the shape manually it works?

#

IE assigning through editor?

stuck bay
#

Good question

#

Imma try that

prime flower
#

That would narrow it down to code

stuck bay
#

It does in fact work

#

Hmm

#

That is very weird

#

I mean

#

the mesh looks fine

#

But it just clips through

prime flower
#

@stuck bay is there a reason you want to do it via code?

stuck bay
#

Because I want to learn about it

prime flower
#

That’s fair just curious if there was a technical reason

sharp dove
#

does anyone know about car physics?

shell night
#

if the camera is the cause, check your culling settings

languid hazel
#

I'm having an issue where collisions are occurring even though the physics layers are set to never interact in the project settings. Does anyone know what could be causing this?

#

The first image shows my layer collision matrix, and the second shows the character hierarchy and the problematic collider.

timid dove
languid hazel
#

It has a box collider, but it's disabled when I'm testing the collisions between the "AirbornCollider" game object.

timid dove
#

also it's possible your movement script itself is doing the collision checks

languid hazel
#

When I manually go into the inspector for the "airborn collider object" and disable the collider, the player can move through the object just fine. That leads me to believe that it has to be the airborn collider that's preventing the movement.

#

Yeah, during runtime the collider is still disabled.

#

I don't know, I feel like it's probably something obvious that I'm completely missing, but I just can't figure it out. BurritoCat

timid dove
#

Or did you disable the collisions in the 3D settings?

#

I think that's the 3d one, as cloth settings aren't a thing in 2D 😛

languid hazel
#

Facepalm Yeah, that was it. Thank you1

iron wing
kind pilot
#

how do i use parent constraints?

#

do i use it on the parent or the child

kind pilot
#

ok nevermind

#

parent constraints is kind of jittery

timid dove
#

It simulates that relationship without them actually being parent/child, and allows you to freeze certain axes etc.

kind pilot
#

i already know now

#

but the car seems to be jittery

#

when i use the parent constraint to the chase cam transform now

empty sand
#

I am working on a multiplayer project where the server needs to substep each player's simulation separately, so my plan was to achieve this with multiple scenes and additive loading. The idea is that the main scene should contain the map geometry and each player scene should operate and do its substepping within that.

So far, however, I can't get it to work unless I duplicate the map geometry as a prefab in each subscene, which can't be right.

Here's my scene generation code:

playerObject = NetworkManager.Instantiate(playerControllerPrefab,
  Vector3.zero, Quaternion.identity);
playerController = playerObject.GetComponent<PlayerController>();

if (IsServer)
{
  scene = SceneManager.LoadScene(SCENE_NAME, new LoadSceneParameters(
    LoadSceneMode.Additive,
    LocalPhysicsMode.Physics3D
  ));
  physicsScene = scene.GetPhysicsScene();
  playerController.SetPhysicsScene(physicsScene);
  SceneManager.MoveGameObjectToScene(playerObject, scene);
}

If I don't duplicate the map prefab, the player object just drops through the floor plane and falls forever. Otherwise it works fine, so the substepping is working, but the multi scene collisions are just not happening. Any advice?

timid dove
#

Objects need to be in that scene in order to be interacted with by other objects in the scene. This naturally includes your "floor plane"

empty sand
#

Is there a better way of substepping multiple player objects concurrently in one scene? Or is duplicating the map a pretty normal practice for Unity physics?

timid dove
#

Multi scene physics itself is pretty unusual in and of itself so I can't comment on what's normal practice

iron wing
#

Hey everyone, how could I make hinged doors that interact with a character controller?

stuck bay
#

This says to ignore layers pass a layermask and only select the ones you are interested in....

#

But its colliding with other layers that I haven't selected still?

#

Physics.Raycast(ray, out hitInfo, layermask)

#

Is this a unity bug?

#

2021.2.19f1

iron wing
#

Could you show me your code? :p @stuck bay

stuck bay
#

LayerMask is an inspector field:

    public LayerMask layermask;```
#

but it also picks up NPC layers... why..?

#
Debug.Log("Hit : " + rinfoSlope.transform.name + " > " + LayerMask.LayerToName(rinfoSlope.transform.gameObject.layer));```
#

Any clues? :c

iron wing
#

Add the layermask here : Ray rSlope = new Ray(transform.position + walkDir, Vector3.down, layermask);

#

it seems like you're using a raycast to cast another raycast

#

In my own code :

#

I don't use this line there :

stuck bay
#

Thats just a ray

#

uhhh

#

if i instead use this it works:

Physics.Raycast(rSlope, out rinfoSlope, float.MaxValue, layermask)```
#

This picks up wrong layers:

Physics.Raycast(rSlope, out rinfoSlope, layermask)```
#

i had a similiar problem in this project before and that solved it there too...

#

oh i remember why >.>

#

its using the wrong overload ....

iron wing
#

I think it's because you forgot to add the max distance yeah

stuck bay
#

yeah and no error becuase LayerMask converts to int

#

.>

#

damn..

#

such a stuupid mistake

iron wing
#

it happens ¯_(ツ)_/¯

hot escarp
#

not sure what channel to ask this in but: Is there a way to make a rotation of a 3d object the new 0?
ex. I have a capsule and I want rotation 0,0,0 to be what would currently be 0,0,90 or it laying on a side.

timid dove
iron wing
loud tide
#

How do you all deal with 3D characters / AI / etc that have unintended collisions with other things and it causes your 3D objects to pop up high in the air. Do you put a invisible ceiling to stop it? Kill zone? Check for Y and if > some # despawn? Do you modify the rigid bodies and etc? An example is spawning out of a simple object spawner, say you spawn and the object doesn't move, now you spawn a second one directly in the first and it pops straight up. I am going to get around this specific instance by just not spawning if there is a object in the way, but I do randomly get pops on stuff like dashing into things etc.

timid dove
loud tide
#

do you recommend kill floors or ceilings for any stray gameObjects that escape the reality of my game 😄

#

or not really and its better to try to not have things pop than kill them off if they do

timid dove
#

it's better not to have them escape reality, but it's also not a bad idea to have something in place to handle them if/when they do anyway

#

You can't necessarily foresee all the issues and the internet is full of videos of people "getting out of the map" in... basically every game ever made

loud tide
#

ok. ill see what i can do thanks

empty sand
viral ginkgo
#

@empty sand I guess thats why you'd wanna use a kinematic character controller for multiplayer

#

It shouldn't be too hard to convert your character to use capsulecast?

#

There's this recursive step you need to do where you cast some capsules and get some projections
To slide along surfaces in 2d or 3d

buoyant garnet
#

Hi guys
Using a "Hinge Joint" why it sometimes completely breaks like in the footage below?
I set the axis to forward (positive Z) shouldn't it be locked to that axis? why it jiggles like that rotating in other axles..?

eternal lichen
#

Anyone knows why the first one doesn't collide but the 2nd does

neat coral
#

is that at runtime?

timid dove
eternal lichen
#

A mesh, I already fixed it, idek how it worked but I just changed their y from 100 to 102 and it works lmao

stuck bay
#

why is the box collider inclined? any way to change it

#

okay i got a solution, adding empty child object

iron wing
buoyant garnet
# iron wing Bumping this because I also have this problem, and nothing online fixes it

Well.. if you just after a workaround, this issue caused by 2 physics objects at the end of the "bridge". when the ball pushes the plank too hard it goes fast beyond your limits and through these two objects.
The "bug" (IMO) is that the hinge then ignores your min\max and axis limits.
I just removed those two objects and now cannot reproduce this glitch.. but this hinge issue isn't fixed.

iron wing
#

Another problem I got with hinge joints is that the hinge himself can be moved?? If you push against the object, the hinge & the objects can be pushed around, and there is no option to make the hinge / anchor FIXED and immovable

prime flower
iron wing
#

it does :/

rocky coral
#

Hi all, I have some cars which when they collide with each other they just float upwards, like they're ignoring gravity, but they both have mass, gravity, rigidbody and colliders, does anyone know what might be the issue?

prime flower
#

But something sounds seriously wrong there

iron wing
prime flower
#

Well only one of them should be kinematic

#

The object that should move on the hinge should not be kinematic

misty mauve
#

Ok, so I've been working on this for a while and I cannot figure it out. I'm trying to "lock" two game objects together rotationally. So if one rotates, the other rotates the same amount. (think like a Fixed joint. Where if one object moves it moves the other and vice verse. And if one object collides with a wall it stops the other for moving too... except for rotation) I'm not trying to have them rotate around each other so I can't parent them. They need to move independently of each other. but rotate together. I've been trying to find the source code for the Fixed joint but no dice. I cannot figure out how to do it. The real problem comes with I'm turning object A and object B collides with something. the physics engine handles the collision and I can't find a way to get it to use that information to stop Object A. Anybody have any ideas? My team and I have been working on this for a week and a half now and we cannot figure it out.

neat coral
#

2d or 3d?

stuck bay
runic harbor
#

I'm going crazy... when I add a mesh collider to my wheels and check the convex options ( must be convex cus the car has a rigidbody ) the colliders arent round... any way to fix this? I tried using sphere colliders but the results are horrible.

#

The mesh itself is pretty round in blender

#

This only happens when i don't use "Apply transform" during FBX export... If i use "Apply Transform" the mesh collider is round. However the axis are incorrect relative to unity axis...

#

I'm going crazy with this

#

So basically:
-No apply transforms: mesh collider not round, but wheel axis aligned with unity axis
-Apply transforms: mesh collider round, but wheel axis not aligned with unity axis

timid dove
#

Wdym by "round" or not

runic harbor
#

if you see the first picture the green collider is not round but more like an hexagon

#

last picture it's completely round and follows the wheel perfectly

runic harbor
jovial wraith
runic harbor
#

fixed it by unflagging "use space transforms" in the fbx export

tough path
#

How can I stop my camera jittering when.I rotate with my Rigidbody player?

#

I tried setting the rigidbody's extrapolation to on

#

that didn't work

#

and I tried making the camera a separate object and having it slowly follow the player

#

but that doesn't work because it's a multiplayer game and I have to keep the camera as a child of the player

#

Any ideas?

neat coral
#

why do you need to keep the camera as a child of the player?

tough path
#

but I don't want to do that because I have to put my NetworkIdentity (using Mirror) on the container

neat coral
#

so what

tough path
#

wym

#

oh

#

sorry

neat coral
#

then do that

tough path
#

No I can't because my player has a NetworkRigidbody component

#

and the child cant have it

misty mauve
# stuck bay use target rotation of ConfigurableJoint

That changes the desired angle of the joint as a whole with each game object on both side... thus moving each game object to a desired position. Im looking to just rotate each object in whatever its location in. We tried that option and cant get the desired results

misty mauve
stuck bay
#

wrong tag

#

wait configurableJoint can actually rotate whole gameobject

vast abyss
#

hello i want to make a active ragdoll character im not sure which joint to use (i dont want a gang beasts or human fall flat kinda character i want to have lots of control over the character kinda like the character feels light and not very heavy i want to make it so the arms legs and head like wabble around alot)

hasty solstice
#

How do I prevent enemies from pushing me around if they use a rigidbody while i use a character controller? the cc doesn't have a kinematic tickbox option, so i'm lost

frigid pier
#

If you just added rigidbody on character controller, it was not designed to use one and will conflict with it. Like I've mentioned I haven't used it in practice but probably it involves manual handling of all interaction events with it if you want interaction. You should find a tutorial illustrating how to setup interaction with CC properly.

shrewd shoal
#

how can I control which objects can interact with other objects but not allowing them to go through each other, basically some physically interact with each other and others treat each other as kinematic but they are not (that way they can use gravity)? pls ping on reply

#

because using Physics.Ignore allows them to go through each other and so does changing the layer interaction to ignore each other

#

and also is this even possible because it would be kinda wack if you cant have 2 objects not push each other and gravity at the same time

muted wave
#

hey so I have a bug in my racing game where when the player(a sphere collider) is on the road sometimes it just jumps like in the video if I get two blocks and let the player drive between them this also happenes so I am gussing when it goes bettween these it thinks it should kinda jump but the height differnce of these colliders (the two ground) in minisculare to nothing so it shouldn't do that and for the road I am using a mesh collider and I the ground isn't fully flat because somewhere in the road it goes up

timid dove
potent ice
#

Hey lads, have a question: I wanted to make a game where the player swings using a chain. The chain is made up of 4 links which each have a Rigidbody2D, CapsuleCollider2D and a HingeJoint component. The chain is then connected and parented to a square sprite with Rigidbody2D and is kinematic. This square is the parented to the player. The chain on it's own works great, but whenever I attempt to move the player it just falls appart. Also the collisions between chains and player are turned off in the Start(); function. Anyone knows a fix?
I will send some pictures and a video.

#

Inspector of 1 Link

#

Inspector of the square parent

#

Hierarchy

#

Joints

#

There is no script written for the chain btw

#

oh and please ping me if you answer

potent ice
#

Fixed it, I just had to use a force rather than position to move my player :D

muted wave
timid dove
#

Why not BoxCast first then move only as far as the BoxCast allows?

BoxCast isn't appropriate for checking if a particular position is already colliding. You'd use OverlapBox for that. BoxCast doesn't hit objects that the box begins the cast overlapping

#

I just watched your video

#

Looks more like a your code problem than a Raycast or BoxCast problem

#

Again you should really just do the check before you move the object and don't move it if there's an obstacle

dense kestrel
#

so wheel colliders are a joke right?

minor berry
#

that is dope

gleaming nebula
#

hey so Im creating a pirate boating game and Ive created a way to keep the player on the boat while its moving by adding the boat velocity to the players velocity so then it follows along, however the player keep jittering with the velocity added. im not sure how to fix this

timid dove
#

That doesn't make sense. Raycasts hit colliders. There must be colliders for the Raycasts to work.

#

I'm also just saying Raycast first, move second.

muted wave
#

how can I stop discrete rigidbody from going through rigidbody as when it is going fast it doesn't detect the other wall and the wall has a rigidbody(but I can remove it if you think that might help) and I have to have the discrete rigidbody be discrete as it stops another bug.

unique cave
muted wave
#

ok so I guess I need to fix the bug

#

again as I thought this was teh way to fix it

unique cave
muted wave
#

The player jumps when moving on the road because the road isn't a perfect flat road and it is also aesh collider

unique cave
#

afaik that's quite heavy process and should be avoid when possible. if you use kinematic rigidbodies on the moving objects and use Rigidbody.position instead of Transform.position, the update on physics engine should be immediate.

#

I'm not sure. some sources suggest objects with colliders on it shouldn't be moved using transform because it can be expensive (physics engine considers objects without rigidbody a static object that is not meant to move)

#

those are mostly quite old pages I have been reading so it may not be that expensive these days

timid dove
#

Why wouldn't it work?

#

But yes you do normally need to wait for the physics update unless you sync transforms manually

carmine basin
#

Is it possible to essentially "pick something up" by sandwiching it between two colliders?

#

Im thinking of physically articulated hands but im not sure how that'd be in both practicality and performance

#

ignore last lmao

graceful oar
#

I have 3 doors, eastern (e) , western (w), central (c). (e) + (w) are opened when a game object that corresponds to those doors are destroyed. The (c) door opens upon both the (e) + (w) doors opening. The (e) + (w) doors can only be opened one by one, but doesn't matter which way round. How do I set a boolean so the (c) door will open regardless of if (e) door is opened first followed by (w) door OR (w) door is opened first followed by (e) door?

brazen echo
#

Having a ton of trouble with Raycasts and Trigger

#

No combination of settings or Query interactions is netting me a Trigger hit

timid dove
graceful oar
#

am i in wrong channel again?

stuck bay
#

Hey guys is there a way to use MovePosition with a non kinematic rb or how can I use moveposition without moving through objects?

timid dove
stuck bay
tawdry crown
#

Hi, I'm having some issues with collisions:

  1. Player is using the character controller and is using charactercontroller.move()
  2. Test object does not register any collisions: player and test object have both colliders, rigidbodies and collision matrix is set up
  3. Made a test collision script for test object with only OnCollisionEnter (actual OnCollisionEnter script is on player)
  4. With the test collision script ON TEST OBJECT, the OnCollsionEnter script ON PLAYER now works as intended (??)

Any idea what's happening here and how to solve the issue?

timid dove
timid dove
#

and if you have a dynamic Rigidbody, that is not compatible with CharacterController

#

unless you're saying the other object has a dynamic RB?

tawdry crown
timid dove
#

show the components on both objects when it does and doesn't work

tawdry crown
#

On the player there is a rigidbody, charactercontroller and some custom scripts, one with OnCollisionEnter
On the test cube there is a collider, rigidbody and a test script with only OnCollisionEnter

This way the player registers collisions but if I remove the testcript on the test cube, the player doesn't register any collisions. So it works, but only if the test object has a script with an OnCollisionEnter.

lilac garden
#

same doors, but one inverted, one hinge joint breaks and the other doesn't. Both have colliders inside

graceful oar
#

I'm trying to get a door to open upon two doors being opened, but the door needs to open regardless of which of the doors are opened first and only after both doors are open

#

the gate index issue i have is, with each gate unlocked, add 1, so the first two gates should make it 2 right and so for the last gate i did > 2

#

im sure thats right how ive done that

timid dove
#

Also your doors are going to fly away into the sunset because you Translate them forever

#

not sure what you mean by "regardless of which of the doors are opened first" because both of your doors just open at the exact same time

#

also why do you have so many random unecessary empty scopes... { }

graceful oar
#

i know before one door opened when a target was destroyed and then the same would happen to the other. now they both open which is not what i want and the hp bar no longer works on one of them. what i wanted was open either door a / b in any order and door c would open one both doors are open (regardless of order).

#

once* both doors

#

the index i was trying to do so that door a and b equals a number and when the number is higher than a value door c would open

#

i know ive probably done it all wrong

timid dove
#

What you're describing and the code you've presented don't seem to be in the same galaxy of functionality 😛

#

I would expect each door to have its own hit points variable for what you described, for example

surreal elm
#

Hey I'm trying to apply gravity to a character that has animations such as idle, walk, etc. The issue I'm running into is that when the game starts, the idle animation is applied, and the character doesn't fall by gravity because of it. Is there any way to fix this?

#

This is the character's inspector:

jovial wraith
#

however, that probably would not work with root motion

#

also, you should not have both a character controller and rigidbody on the same object. Use one or the other

surreal elm
#

Alright I'll try that, thanks! Is there a reason why the physics and animation get wonky like this if they're on the same gameobject?

#

And thanks I'll remove the character controller

jovial wraith
#

by creating a hierarchy of GameObjects, you're telling the two systems how to cooperate

surreal elm
#

ahh alright that makes sense. Thanks again for your help, I appreciate it

dreamy pollen
#

I don't think you need to slap kinematic rigidbodies on everything that moves anymore... isn't this what the "static" checkbox is for?

stuck bay
#

I'm trying to make a pinball game in unity, what scale should I apply to my table? thanks in advance for the tips

lethal wren
#

Scale 1 to my mind
But when you need to scale down an object (like the ball) wich have a collider, put this object in an empty parent, and scale the parent

#

for object wich have collider etc, the best practice is to let his scale at 1,1,1

muted wave
#

hello so I have a road I made in blender and then I import it to unity and give it a mesh collider I want to know is this the best option as then my player(a sphere collider) bumps into the ground's small changes in height causes it to kinda jump I was told I need to make the ground seemless does that mean I need to change my way to give it a collider?

#

this is the bug

lethal wren
#

can you show us the collider ?

muted wave
#

it's just a sphere collider but

#

I was told to maybe make a script in order to keep the sphere collider(player) on the ground but I think I didn't do it well

#

if (grounded == false && stickToGround)
{
Debug.Log("going down");
rb.position = hitPoint;
rb.position = new Vector3(rb.position.x, hitPoint.y -(0.989f), rb.position.z);
}

#

esciantially It checks if the player is on the ground if not it tries to bring the sphere collider(rb which is the collider of the player) to the hit point but a bit heigher up so it just touches it

muted wave
#

never mind I was able to fix the problem in the brackeys server thanks to a user called molibloo.

jovial wraith
# dreamy pollen I don't think you need to slap kinematic rigidbodies on everything that moves an...

That information looks correct to me. If it moves and interacts with physics, it should have a rigidbody (and the movement should be controlled via the rigidbody, not by moving the transform directly). The part about triggers not working without a rigidbody is definitely true.

That article was updated in Feb, 2021. That's not that old and the Unity physics system has not been totally overhauled since then.

If you don't believe the info is current, it's not that hard to profile the difference yourself. Just make scene with a bunch of interacting objects and try it with rigidbody vs without rigidbody and check the profiler.

earnest nymph
#

so this is what the enemy reptile should look like

#

but when i hit play he is in the ground

#

it has a nav mesh agent on it

dawn plank
timid dove
#

where is the pivot point period? Make sure you have tool handle position set to Pivot, not Center.

#

And... probably yeah your code is just dumping him in the ground

iron wing
#

Hey everyone! Im having a problem considering hinge joints, I don't know why, but they all start flying into the distance when I press play, or touch them.
Here are the components they have, (the 4 wheels share the exact same component, I linked all objects for better reading)

iron wing
#

Problem solved! The constraints of the rigidbodies were causing it!

earnest nymph
dawn plank
earnest nymph
#

base

grand flame
#

hello

#

i am making a mobile fps

#

i have created the movement,shooting,AI and the map but the problem is i am trying to create a health system

#

the health system should update everytime the AI shoots me (i am using the Raycast feature for the shooting on the bot)

#

i found a tutorial but instead of using raycast he made a projectile and used the istantiate function.

#

can anyone help me make the health system please

atomic lintel
#

is there anything similar to Chaos in Unity that unreal has?
Like you could create objects that shatter and break

Closest i got to it was make a blender model then cell fracture it then add rigidbody, mesh collider and a fixed joint to all the cells then when u shoot it for example the object shatters. But if the fixed joints have no connected body they dont have gravity so the object just like floats in air after you shattered the support. Then if you add a connected body to all the joints it just shatters instantly.

timid dove
atomic lintel
#

I was planning to make like big complex objects able to be shattered and broken. So if there would be like a tall building you could shatter the bottom and then at some point the building would fall and shatter even more when hitting the ground. I got it working pretty well with unreals chaos system but idk if something like this can be done in unity atleast easily.

timid dove
#

yeah rayfire is made for that

#

not free though

#

I have no knowledge of Unreal features so not 100% sure what I'm comparing to

unique cave
#

I think chaos is free built in destruction system. That unity doesn’t have but you can use assets made by others as praetor is suggesting (or build your own system which sounds very complicated)

rough lodge
#

For 2D, how can I handle slopes? I have a circlecollider for the ground, but I slide down slopes

#

Increasing friction makes me unable to climb them

lapis plaza
#

there are some nvidia blast integrations for unity

#

@atomic lintel^

#

pretty sure unreal used to use nvidia blast for their fracturing framework too (to be simulated with chaos)

#

blast is essentially what is successor of their apex destructions fracturing tools, it's just different concept now

#

(ue4's destruction was still apex based - unless you went to experimental chaos builds)

sweet ferry
#

Does anyone have any resources that could help me make an active ragdoll? (Unity)

dreamy quail
#

i am working on a rigid body vr hands set up
the tutorial im following says to use primitive colliders
i want to use a mesh collider

#

will this cause a problem

dreamy quail
# sweet ferry Does anyone have any resources that could help me make an active ragdoll? (Unity...

This is all I learned while making active ragdolls in Unity. I hope you find it useful or, at least, interesting :D

The actual tutorial: https://bit.ly/3lKsfk2
Github repository: https://bit.ly/2VxnU98

----- Social -----

Twitter: https://twitter.com/sergioabreu_g


Ambient Generative Music by Alex Bainter [generative.fm]

-...

▶ Play video
timid dove
#

mesh colliders will be ok for individual pieces of the doll as long as they are convex.

#

and as long as you aren't expecting them to deform with the mesh

trail sphinx
#

I can't figure out why ragdolls created using the wizard on Mixamo character rigs are getting stretched, ive tried re-doing it like 5 times with 3 different rigs in t-pose:

#

ive had plenty of success with this in the past but its been a while, not sure what im doing wrong

graceful oar
#

Hello I'm still having issues of when the two lower gates in the highlighted picture, when they go down (see gameplay video) the upper central gate is supposed to go down as well

#

both lower gates need to be down but can be moved in either order, just need the central gate to register that

#

I've tried doing this with a gate index

timid dove
magic girder
#

hi
i made a parachute acctually my friend did and now we dont have the file we only have it on workshop steam we want to download this mod and split some parts like we made 2 parachutes we want to remove one of them can any body help us to split them from each other (just take one and remoe other files)

graceful oar
abstract cobalt
#

Are there any method for making liquid physics. Like pour, shake etc

atomic lintel
turbid geyser
#

So I'm having an issue where OnTriggerEnter2D isn't being fired in a certain scenario. I have a Collider2D that I'm toggling enable state on. If the target object is already in the collider's space when the collider has its enabled set to true OnTriggerEnter2D surprisingly does not fire. This only happens if the rigid body has 0 velocity. If the object is moving, then OnTriggerEnter2D will detect the target object.

Is this expected? Or is this a bug?

turbid geyser
#

@timid dove Roger, thanks.

#

Is there a common known solution? I feel like the hack would be to switch to stay instead of enter and add logic. We did notice that toggling"IsTrigger" as well solved it.

bleak umbra
sleek creek
#

uh super noob question, I assume these red and blue spheres are the joints from the animator or something?

#

For some reason they sometimes desync/follow a different physics system than my actual model. Any idea why/where to access them?

rough lodge
#

why is this happening? (Blue is perpendicular, Red is normal)

rough lodge
#

nvm, had to change the raycasts from starting in transform.position to groundcollider.bounds

#

though how do I make it so that it doesn't kinda "fly"/start falling when it's at an angle where it should be able to walk?

trail sphinx
#

Ok im back asking again about ragdoll, it seems like my ragdoll joints are breaking but they have infinity force, screenshot from the frame before and after being enabled

raw lance
#

So I tried adding context to my mesh collider and it didn’t enable collisions

frigid pier
raw lance
#

I didn’t code the physics?

#

I’m not interacting with physics in any of my code

timid dove
raw lance
#

Because there is two colliders? Do you have to code collisions in 3D?

timid dove
#

You need more than just colliders

#

you need a dynamic rigidbody

raw lance
#

What do I need?

timid dove
#

and you need the object to not otherwise be moved/positioned by your code or other componnents like animators/CharacterControllers

raw lance
#

Dynamic rigid body I did not know that

timid dove
#

Rigidbody is the thing that the physics engine actually simulates

#

without it, there is no physical simulation at all

raw lance
#

I have a regular one

timid dove
#

A "regular" Rigidbody is a dynamic Rigidbody

timid dove
raw lance
#

Oh then I have one already

#

I move it only with the rigid body atm

timid dove
#

how are you moving it

#

show the code

raw lance
#

Sec I just posted it

#

Here you go

#

But it falls through the world long before I try interacting with it

timid dove
#

the code looks ok

#

You must not have the proper colliders set up

#

maybe show the inspectors of the two objects you are hoping to collide with one another?

raw lance
#

I just changed from a box collider to mesh collider

timid dove
#

show it

#

show the inspector of the moving object

raw lance
#

One moment

timid dove
#

and the inspector of the object you want it to collide with

frigid pier
#

setting velocity in Update

timid dove
#

should be fine as far as respecting collisions go

#

they'll have a problem with setting y velocity to 0 and presumably having gravity enabled

raw lance
frigid pier
raw lance
#

Oh, my bad, i turned it off for testing

#

it doesnt change the results anyways'

#

im sure its a stupid mistake but i cant see what im doing wrong

frigid pier
#

Should start with simple configuration to make sure you didn't make any mistake. But what you really should do is to follow Unity Learn course covering physics. I think Essential Pathway covers it as well.

raw lance
#

Oof it was going through the world, it was physics going cracked

#

ill chat that out

#

in 2D i didnt really have to worry about this as much

raw lance
#

This is my first dive into 3d so a lot of new stuff

frigid pier
#

There's a very good reason to go through well structured courses instead or relying to grab what you need currently from random tutorials or even manual.
You'll be exposed to almost complete set of features, including some that you would encounter only randomly stumbling into.
So you would be able to play with full set of tools. Even if you don't remember how everything works you'll be aware of it and know where to find information about it. And would be much better equipped troubleshooting stuff like this.

raw lance
#

Im going through it right now, thanks

spark crest
#

im working on a vr game and for some reason the hands keep clipping through objects
i tried increasing the physics iterations but it doesnt change anything

#

the radius of the sphere hands that im using are 0.2

timid dove
timid dove
raw lance
timid dove
old spindle
#

Simple problem I can't seem to solve.

I have a physics mat with bounce = 1, bounce combine = max, friction = 0, friction combine = min
I have a ball and paddle with this mat applied
I have walls with colliders but no physics mat

When the ball collides with the wall, it bounces off with no decrease in velocity.
When the ball collides with the paddle, it bounces off, but loses a good amount of velocity.

No scripts doing anything other than spawning the ball and giving it an initial force.

old spindle
#

kinematic, but atm it's just standing still

timid dove
#

so when it bounces against the same material it loses energy but with the default material it bounces nicely?

old spindle
#

yeah

timid dove
#

that does seem odd...

old spindle
#

if I remove the mat from the paddle, it still slows down

#

tried lots of configurations but can't figure it out

timid dove
#

screenshot of the scene?

old spindle
#

sure, sec

timid dove
#

what happens if you remove the Rigidbody from the paddle too? (you said it's not moving currently, right?)

old spindle
#

let me try that before I take a few ss's

#

ah, does not lose speed when I remove the rb

timid dove
#

interesting

#

I cannot explain that to you... but at least we seem to have found some kind of pattern

old spindle
#

I added the rb back and now it doesn't slow down... such is life

#

thanks @timid dove 🙂

timid dove
#

I'm not sure what I've done but you're welcome haha

tiny cypress
#

Hello. Is it possible to do like a Vector3 MoveTowards that takes a vector3 for speed, instead of a float?

#

I'm adding acceleration to my system, and there's a bit of "snow/icy" slipping to the movement. So I always want to be MoveTowardsing a target, but not necessarily directly towards it every time

#

I was just adding accel to my velocity, and then adding velocity to my current position, but I end up overshooting the destination

jovial wraith
#

the easiest way to do 1) is to just stop instantly when you arrive at your destination. That's what MoveTowards does

#

the naive approach to doing 2) that you already tried made you overshoot

#

in order to do both 1) and 2), you have to predict when you are going to arrive and start slowing down BEFORE you get there, so your velocity gradually approaches 0 as you get closer

#

that's not a particularly easy problem to solve in a really general way

#

though that's probably more complicated than what you're looking for

tiny cypress
#

Thank you Tachyon! I had a nagging feeling that I was trying for something fundamentally impossible, but couldn't tell you why. That crystalizes the issue a lot

#

And I don't think I need a perfect solution, but that has me thinking. If I can decrease velocity & maybe increase acceleration (so the velocity is more directed towards the destination) then I think it'd be good enough

#

And holy crap this PID article is amazing, I think this is the answer to something about my car I've wondered about since I was 16 clapping

timid dove
#

like - how does cruise control work?

vast abyss
#

hello just wandering if u could make dashes and grappling hooks with character controllers as i think u can only do so with rigid bodys

wide nebula
#

Yes you can

#

It would require some strong math. It would be easier to do with a rigidbody.

runic harbor
#

Anyone knows how i can rotate the wheelcollider contact point ( the little bubble on the left ) so that it faces down?

#

nvm solved

#

i rotated the parent object instead of the object containing the mesh

fallow harness
#

my wheel collider is in the wrong direction. how can i fix that?

timid dove
#

it's not the wheel collider that's in the wrong direction, it's your model

fallow harness
fallow harness
timid dove
fallow harness
#

ahhh okay thanks !

abstract cobalt
#

Hello I want to make physical water and I want t add pour effect to it. Can somebody help me (I dont want an asset I need a tutorial, doc. or something else)

timid dove
#

either find an existing asset or start reading SIGGRAPH research papers

abstract cobalt
timid dove
#

Maybe look into marching cubes to start with. That's one way to render "blobby" amorphous kind of objects

atomic lintel
#

so is there no way to make the mesh colliders work properly with rigidbodies. Like if you cut a hole in a cube with blender then import it to unity and add a mesh collider to it, the collider completely ignores the hole in the cube. If you turn convex off in the mesh collider then it works perfectly but then you cant use it with a rigidbody.

#

Why did they even remove that functionality. I dont want to downgrade to unity 4 :c

#

Like i simply have a cube with a hole in it. It wouldnt take alot of resources to allow the mesh collider to work properly on it but with convex enabled it just puts like a box collider on it and ignores the hole

timid dove
#

You can just build a Collider up out of several primitive colliders such as BoxCollider

slender hedge
#

Hey, I was wondering if anyone had an idea why I can't get my ArticulationBody to move using drives. No matter what target I set, nothing is happening. I'm using the SetDriveRotation extension method here (https://gist.github.com/Gustorvo/50fb28e7b348f4a3f74c631891c535bf) and I see it is changing drive values in the editor. This is what my editor looks like...

jovial wraith
slender hedge
atomic solar
#

Is there a way to assign different gravity values for different objects in 3d?

#

I want to change the players gravity dynamically throughout, without changing the gravity of everything in the scene

jovial wraith
spark crest
#

is there anything i can use other than a mesh collider as collision for a mesh

swift egret
#

if i have a 2d top-down third person game where you can move around as the player character and there are enemies that chase you, should i make them use dynamic or kinematic rigid bodies? i thought the latter made more sense but then i discovered that kinematic objects arent stopped by static objects. should i make even the objects that will never move kinematic to get around this issue?

bleak umbra
#

You’d handle collisions or rather avoidance thereof, through some form of navmesh and local avoidance

swift egret
#

but does that mean bad hitboxes for the static objects then

bleak umbra
#

Define ‘bad’

swift egret
#

well wonky and something that clearly doesnt fit the sprite

#

are we talking about a grid based solution

bleak umbra
#

up to you to implement a nicely working navmesh/grid and proper avoidance movement for your game

#

still simpler than making ai work with forces and random collisions

swift egret
#

i see but how do i implement collisions for the player character

bleak umbra
swift egret
#

so like make it cast rays in like four directions or something and see if any ray hits something within the radius of the players hitbox?

#

can i just make the rigidbodies dynamic and find my own way to deal with the AI problen

#

i mean the enemies arent meant to be very smart here, theyre like rpg battle initiator triggers

#

which happen to be monsters of which many arent that smart

#

in that vein i wanna ask how you can disable ricochet effects because i dont want those in this game

#

apparently theres a material property named bounciness you can set to 0 though some people online have said that doesnt always work... i guess ill try it anyway though

stuck bay
#

what is the alternative for puppet master ?

prime rain
#

How exactly do I use the inertia tensor to calculate torque given angular acceleration vector?

jovial wraith
# prime rain How exactly do I use the inertia tensor to calculate torque given angular accele...

The moment of inertia, otherwise known as the mass moment of inertia, angular mass, second moment of mass, or most accurately, rotational inertia, of a rigid body is a quantity that determines the torque needed for a desired angular acceleration about a rotational axis, akin to how mass determines the force needed for a desired acceleration. It ...

#

Use it to calculate the scalar moment of inertia around the axis that you have acceleration (see the Wikipedia link for the equation)

#

Then use the standard torque formula to find the corresponding torque that would result in that acceleration

brave geyser
#

Can someone tell me plz how to change the motor speed of a slider joint in unity2d in c sharp

snow leaf
#

Help, i added a platform effector 2d but it just doesnt show in the scene

alpine jolt
#

I'm wondering if someone could give me some guidance. I have a number of clickable items in my game and I've noticed that when the frame rate is not as good as it should be they stop working. Is there a way to poll collider interactions more often or at the same rate regardless of what the frame rate is?

stuck bay
#

I have rigidbody 2d components on player and enemy. should I set interpolate option of both of them as Interpolate?

kindred lion
#

how do i fall faster without increasing gravity or mass

#

cuz when i increase grav and mass my walk becomes too slow

merry relic
#

anyone know how to have this tilemap collider become like straigh

jovial wraith
jovial wraith
fading moth
#

Is there a way to disable springing in Configurable Joint like in a Hinge Joint?

elder swift
#

Guys, with physicssimulation, how would I go about doing something similar to Physics.Raycast(ray, out hit, 100, m_LayerMask)?

civic field
#

as you can see my hitboxes are fine, but somehow my character hovers over the platform

#

it falls just right but just stops too early

#

Any ideas, i'm out personally

elder swift
#

Check the platform collider boundary

elder swift
shut hill
#

hey guys how do i fix this bug of the character shaking when colliding with the wall?

carmine basin
#

I've got an active ragdoll setup working, but the fellow is a little shaky and veers off to the side. What methods do people recommend for stability? I'm currently keeping the hips upright using the configurable joints forces, though i may move that to a kinematic configurable joint which pulls the character towards that, then move using that.
Tldr; how to i help stabilise my active ragdoll to prevent veering to one side?

timid dove
carmine basin
timid dove
carmine basin
#

I do love me some physics
your options are as praetor said.
If you want to learn about physics, there's a website available called Physicsandmathstutor, which has loads of stuff in it. its aimed at gcse and a level students but its good for anyone. hope it helps if you choose to check it out ^^

kindred lion
#

since weight is mg and weight is the force that pulls you down

#

and air resistance tries to keep you up

#

you break through air resistance faster with more mass and less surface area

#

amd increasing gravity but keeping friction/drag constant also means the weight of the object (the effective inertia) is greater so it takes more force to make it walk on the ground

kindred lion
#

acceleration due to gravity is always the same but air resistance applies force in the opposite direction

#

hence a feather falls slower than a brick

#

i suppose unity doesnt have air resistance ig

carmine basin
#

Unity has linear drag, which is the drag field on rigidbodies

i also found with my character than heavy legs is good for making it walk

#

I might play with the mass scales, since heavier rigidbodies tend to be more "responsibe" to configurable joint rotation motors

civic field
#

i'm still super confused

#

used Unity for a while never encountered

#

and my scene is just these two objects

carmine basin
#

Crossover question between Physics and VR but in the case of an active ragdoll for the player, how would one keep the head still and sync it with the head's tracked pose driver?

vast axle
#

Hello, how i line my colliders prefect to fit these peaces under each other? In photshop I made them in same size everywhere.

timid dove
#

If you are making Tetris I highly recommend not using the physics engine.

merry relic
#

for some reason my floor falls whenever i click play

timid dove
merry relic
#

it worked thanks. And if i want my character to not fall thru the floor would i need to add a collider on both my charachter and the ground?

twin nebula
#

Is there anyway I can make Angular X and YZ drives object space? I want to be able to parent 2 cubes to a bigger cube and say if I twisted the big parent cube they wouldn't try to correct themselves on the Y and Z

#

I'm not too familiar with the angular drives but honestly anything like that would be good

#

Ooh wait I just figured it out. My bad!

twin nebula
#

Is there any way I can make this only limit one side? Right now this sets the limit on both sides. I'm trying to make sure the elbow doesn't bend backwards

carmine basin
#

Why is your axis set to 180?

#

It only needs to be set to 1, having it set higher has no difference

#

also

#

Try playing with the primary axis until you have the x axis of the joint is along the bend of the elbow

elder swift
#

maybe you've done like I did yesterday and added a second collider not realizing I already had one on an object?

civic field
pliant fern
#

I haven't been able to figure out how to make a realistic inner tube for a water slide, currently I'm just using a sphere collider and locking the inner tube's rotation, but that's not very realistic to how an actual inner tube would behave (as you can see, as it goes on the walls, the rotation doesn't make sense). How would I go about doing this?

#

I understand why this is happening at the moment, but how would I implement physics that would make it more realistic to an actual tube slide?

#

I've asked this a few times in the past year but I haven't found any solutions. If there's anything that you want me to clarify I'd be happy to

#

I've already tried a mesh collider, but with that it got stuck, and multiple primitives didnt work either

#

I'm thinking some path based system where speeds change? I have no clue where I'd even start with that though and i don't know how i'd implement the tube reacting with the sides of the slide

#

I think I'm getting kind of close

#

Making the slide and the tube zero friction seems to help

#

but it also makes it jump up into the air randomly

#

like spin out when it shouldnt

jovial wraith
jovial wraith
# pliant fern e.g.

tbh, this might actually be realistic behavior for an empty innertube on this kind of slide

#

it flips over fast, but bumping up and moving chaotically seems reasonable

pliant fern
jovial wraith
#

next level might be actually setting up a ragdoll to act as the person's weight

#

I'm not 100% confident this approach will solve your issue, but it might

#

I'm assuming you actually want to simulate it

#

if you just want it to look good

#

just making a bezier curve path for it to follow might be easier

#

🤷‍♂️ or that might be 10x harder

pliant fern
#

idk if that will be reasonable for the game i'm making

#

Since in it you'll be able to make your own water slides

jovial wraith
#

this is probably not helpful, but in my undergrad physics classes marbles rolling down curved tracks like this was the classic example of a problem where Lagrangian mechanics is easier to use to solve the problem than Newtonian mechanics (just offering keywords to search if you'd like). Theoretically you could bake a solution to the equations and precalculate the path you'd take down the slide and follow that path instead of doing a realtime simulation of it. But... it'd probably be a pain in the butt

jovial wraith
#

I've never tried to do a simulation like this in Unity, so I'm just guessing as to what's going to work.

pliant fern
#

I don't expect many have tried

#

considering how specific it is

jovial wraith
#

there's quite a few marble run games. This is pretty similar to that

#

trickier, but similar

pliant fern
#

fixed joint is kinda working but it gets stuck going up

jovial wraith
#

I wonder if you need some kind of force field pushing it forward to simulate the water flowing down the tube

pliant fern
#

fixed joint seems to weigh it down a lot

#

I can't find any documentation to put me in the right direction

pliant fern
# pliant fern e.g.

still acts like this, tried adding another object with more mass with joints, increasing mass for the rigidbody, and nothings worked

#

when it doesn't have the zero friction material it doesnt slide at all

#

it just rolls a little and stops

weary moon
#

Which object needs to have the OnTriggerEnter() function? can either have it, or does the object with the trigger need to have it

abstract cobalt
#

hi, can i ask a question about a asset inn here

brave geyser
#

Hi, I am making a game based on physics2d..so I want to move player using forces not velocity. but controlling with forces is not smooth. is there proper way to do it

#

plzz help, I am trying to find a way for months

frigid pier
brave geyser
# frigid pier There's nothing inherently "not smooth" with forces. If you want help you need t...

Yeah, my player is basically a box and entire world and game depend on all physics. when I use rigidbody2d.velocity to move it, player is moving fine...but when I interact with hanging objects (I have physics ropes and items hanging end of ropes, I use them to cross some places by jump over them) they are not moving independently while player is on them, I think their velocity is affected by player even player is a child under that object. And I got other problems as well. When I use physics forces...all fine but I have to use liner drag to control movements, due to large linear drag its gravity motion or vertical motion also affected. without linear drag some how makes player uncontrol with forces, it move instantly and hard to control. Also stops while after I hold up the key...So I need some physics moment as smooth as velocity moments like in game LIMBO. I think it needs some extra calculations or something right. thank for any help in advanced.. sorry for long expression

frigid pier
#

Parenting does nothing for physics objects, it's just a container in that case.

#

drag is nice to control maximum speed of physics object, don't use it to stop character though. Instead when direction input is not used multiply Vector3.x of the velocity by a very small number and feed it back in to overriding and arresting momentum. This way it's not completely instant and you have control over it

#

Also with drag present you would need to add some constant downforce to have character fall more naturally

#

Physics based controller if a bit fiddly and you need to cover some corner cases, but it handles more naturally than complete override and keeps natural objects interaction.

brave geyser
frigid pier
brave geyser
frigid pier
#

You take the value, multiply to a small number to reduce per physics frame, and then assign it back

#

X only because you don't want it to affect the jump

#

It should happen when move controls are not touched

brave geyser
frigid pier
#

This code should be in FixedUpdate as well

brave geyser
frigid pier
#

note to not add button presses checks in fixed update. This input works in FixedUpdate only because it's axis based.

brave geyser
#

not buttons

#

I want some thing like, that when I hold or press the arrow key player should move with its high speed (not an accelerating) and when I hold up the key, player should stop instantly

frigid pier
# brave geyser do you have a tutorial or something sir

It's a simple trick to reduce momentum.

[SerializeField] Rigidbody2D rb;
void YourFixedUpdateRunningMethod(){
  // if your horizontal input is not pressed here run this code
  float smallNumber = .01f;
  rb.velocity = new Vector2(rb.velocity.x *smallNumber , rb.velocity.y);
}
brave geyser
#

ahh, you mean when I dont hold my arrow keys, use this code to stop player from moving. right

frigid pier
#

yes

brave geyser
#

on opposite way

frigid pier
#

not just stop but smoothly force to a halt

brave geyser
#

okay I will try it, thanks,

brave geyser
little flicker
#

Heya, I'm trying to get around the "Non-convex MeshCollider with non-kinematic Rigidbody" issue. I've got an airship that i want to apply physics to via a rigidbody (i tried the non rigidbody movement and it was horrendous in VR), the convex mesh collider for it is awful and the overall shape i feel is potentially too complex for a compound collider so I'm having difficulty actually applying the rigidbody in a way that works. Do you know of any other workaround for this?

timid dove
little flicker
#

my fear of that is that it'll feel weird to interact with the ship in VR unless i go through adding each individual step etc.

#

idk why but in my head that's too many colliders and counter intuitive ?

slate copper
#

I need some help boys, I'll send a video in a sec

#

As you can see what i am first doing that is how it should rotate, Is there anyway i can make so the gun also follows along without it being werid

#

look the whole video and you'll understand what i mean by werid

viral ginkgo
#

@slate copper You see where it says "center"?

#

Make it "pivot"

#

And if that doesn't make the rotations correct, the problem is in the model

slate copper
#

alr let me try 😄

viral ginkgo
#

Btw this won't affect how the transform.rotation, Rotate etc works

#

They are all from pivot by default

slate copper
#

Thanks man

viral ginkgo
#

np

spark comet
#

Any body know how to make a good car??

viral ginkgo
#

@spark comet A single body car or a proper realistic car?

spark comet
viral ginkgo
#

Hmm, I'd try to have a single body and worry about the wheels at all

#

Then I guess there arent many things that can go wrong

#

I don't know if you are doing it this way or maybe with wheel colliders

#

Or something else perhaps

#

Maybe pushing the vehicle or wheel down will help you achieve better grip

#

Or maybe you just need to configure the wheel colliders better

#

Maybe you can copy and paste some values from an existing vehicle that's made with vehicle colliders (if you have vehicle colliders that is)

spark comet
viral ginkgo
#

I don't have a car thats good enough to show here, it was an overly complex one

#

And I don't know of one that might suit you

#

But if I were to build one as I said, I'd explore the solutions with a single body

#

I think rocket league also would have single body cars

#

With a single body vehicle you can configure the static, dynamic frictions

#

And it'd work more robust

viral ginkgo
#

Because there's just one body

#

You just have a zero friction box

spark comet
#

???

viral ginkgo
#

A single rigidbody box and thats your car

spark comet
#

Can you just add forces let me look it up thx

viral ginkgo
#

you can lift it via raycasts from 4 corners if you want

#

to simulate the suspensions and stuff

#

There should be assets that does this as it'd be a common use case

spark comet
#

Hhmmm thx for the ideas I’ll do more research

viral ginkgo
#

np have fun

gentle oxide
#

Which character controller should I pick for fast fighting game? Character Controller looks good but has no physics (don't have experience yet to code my own gravity/mass). Rigidbody is nice but has no things like walking on stairs etc.

#

I mean which one would be better in that case and easier? Is it even possible to tell?

elder swift
# civic field there is a rigidbody on the top one

Sorry with all the delays in response, trying to hash out my own errors that are getting on my nerves. Wish Unity would put out something that just worked with out all the crap weirdness. Rigidbody is good but what about it's boundaries? No duplicate colliders? You mind sharing on github? Or maybe setup a temp project with simlar setup and share on Github? I will take a look

civic field
#

there is everything about the scene here

#

if you really need the scene i'll share it but I don't think a scene this simple needs it

neat coral
#

you objects are wayyyy too small

#

0.03x0.05

#

make them proper sized

carmine basin
#

good morning
need help with something - I want to stabilise the head of an active ragdoll character, enough to make it suitable to use for a camera, or to find an alternative

#

Would I just use the head and hands as normal with the vr controls and follow them with the ragdoll?

stuck bay
tight topaz
#

"Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5."
Hi, I'm trying to make a boat with crest oceans, but on collision, it goes straight through. I can't use a different collider or make it convex, because the buoyancy script relies on it to work.