#⚛️┃physics

1 messages · Page 74 of 1

civic field
burnt kite
#

is it possible to attach a animation from mixamo in a gameobject in unity?

#

Idk if this is the appropriate chat

#

let me know if it isnt

desert wave
burnt kite
#

I mean, can I apply the animation in my player?

#

the player is a different mesh renderer

#

avatar

#

idk

desert wave
#

yes i think

timid dove
tall monolith
#

Hey do anyone know how to make the player add force onto the other objects by ran them up, like in karlson, dani make it so like he would bump into billy and make him fall down and kind of bounces off like adding force to it, do anyone know how to make that in unity

worn kindle
#

Hey, how can i change the shape of a hitbox of the box collider 2d? I have a triangle spirit, but the hitbox is a rectangle

timid dove
#

Look into polygon collider

worn kindle
#

ah thank you

brisk plaza
#

Hello! I'm trying to make room in a level of a platformer game by moving things to the right. The issue is that the game is prefab-based and some objects have trigger areas that do not move with the object itself. Is there a way to quickly select and move like half of the level?

civic field
#

Why are the colliders not attached to their objects ?

#

and why can't you move both the colliders and their objects the same amount if they are not connected

#

And why would you need to move everything in the first place

desert wave
#

with rigidbodies and colliders

past grail
#

How can this happen at all?

fallen oyster
#

How do I stop a 2D object from moving?

lilac night
#

Mostly depends on why it's moving.

#

And whether it's got velocity or is being lerped to a position (or some similar effect)

fallen oyster
#

I just figured it out myself, I needed to set constraints. I'm gonna' see if that worked.

#

Nope, fuck.

timid dove
lilac night
#

@timid dove It didn't work on mobile for me but apparently the stack of 5 boxes collapses into 4 and kind of bounces like a spring.

tall monolith
#

Thanks

sleek mantle
#

I am having a little trouble with rigidbody2.velocity.y

#

the rigidbody inspector is showing incorrect values for my player's y velocity

#

you can see in the vid above that rigidbody inspector is showing a value of 7.67128e-06 or something when moving on x axis and shows 0 when it slides down of ladder

#

does anybody know why this is happening?

drifting ermine
#

If there is a really fast and brief collision onEnter is called, but onExit is not.
Does anyone know how to fix that? I have to add and remove the colliding collider from a list

shell adder
drifting ermine
#

Ah the head was still at discrete yeah

drifting ermine
#

That fixed it!

#

Thanks
Also, whats the exact difference between continues, continues spec and continues dyn

hushed fractal
#

the axis is wrong , i fixed that but still the mesh doesnt follow the physics

#

Nevermind , I found the problem. The object was marked static

spice kite
timid dove
#

idk it could literally be anything

#

is this vr?

#

Are your objects thousands of units away from teh origin?

spice kite
#

This isn't VR, not sure about caffeine haha

shell adder
# drifting ermine Thanks Also, whats the exact difference between continues, continues spec and co...

sorry i didn't see this but discrete is the default setting where collisions are checked every frame, use this if you have no fast moving objects
continuous is where collisions are detected in between frames, use this for objects that will collide with fast moving objects
continuous dynamic is for objects that move fast and so is also checked between frames, so use this for the object that will move fast
meanwhile continuous speculative is the same as continuous but it's less resource intensive, and i think that's cus it tries to guess where objects will be and instead of checking inbetween frames it does collisions based on that guess, so use that if you have performance issues
the docs have some info here https://docs.unity3d.com/ScriptReference/Rigidbody-collisionDetectionMode.html

drifting ermine
#

Thanks a lot!

shadow seal
viral pilot
# spice kite Does anyone know why my character shakes?

it definitely looks like you are running out of precision, try moving your character onto 0,0,0 and see if it fixes it, Unity currently does not support camera relative rendering, which means object over certain distance from origin 0,0,0 will start getting out of precision

spice kite
#

Ah okay, might be why because I've moved the object

north egret
#

Hello have a simple question,
how is the addforce mesured?
is 1 meaning enough force to traverse 1 block?
or is it a force like newtons?

timid dove
#

it is like newtons

north egret
#

so say i zero friction how much force will it take to move 1 block/meter?

timid dove
#

If you apply 1 unit of force for one second it will accelerate the block to one meter per second of velocity

#

assuming the block weighs one kilogram

north egret
#

ohh ok i see thanks

timid dove
#

F = ma

north egret
#

ok

timid dove
#

notice the "apply it for one second part".

#

normal force is meant to applied over a span of time

#

meaning over the course of multiple FixedUpdates

north egret
#

so is there a way to know how much force is need to launch a ball in an arc to hit a specific position?(sorry im not that good in physics)

timid dove
#

yes, there's a whole field of study called physics and a set of equations called kinematic equations that are designed to calculate that kind of thing

north egret
#

ok imma do further research ig

#

thanks

timid dove
#

typically with kinematic equations you can determine the appriopriate starting velocity and angle you need to launch the object at to land at a particular place

#

if you know that you can simply set the velocity as desired and not worry too much about how much force would actually be required to do it

shadow seal
#

dear god

#

that's exactly what I learned this week in physics

#

it's coming in handy!

shell adder
#

wow school is useful (sometimes)

shadow seal
#

let me see

#

uhhh

#

I think I think better after eating

spice kite
#

No, it did. I had it set to 500 100 700

vernal sable
#

hey guys how could i detect in a good way the collision? because my projectile sometimes pass through without trigget OnCollisionEnter :/

timid dove
gray falcon
#

Can someone help me understand this formula. I cannot figure out why this does not take into account the "density" of the body in the water. i.e. if its made of wood it's gonna be 50% less likely to float than if it was a beach ball.

Applying this to my boat, if i pull it deep under water, it orientates itself pointy end first (very cool), but then it shoots out like a rocket, but I would have expected the buoyancy force to be significantly less

burnt plover
supple sparrow
gray falcon
supple sparrow
#

It's more about the density of the object compared to the fluid

gray falcon
#

I guess if it has applied this to a rigidbody, and that has gravity enabled & has a mass configured it should even out

supple sparrow
#

Buoyancy will fight gravity, sure. But mass shouldn't affect the result

#

You could mess with rho if you want to really tweak what floats and what doesn't, see what you get

#

density of water is assumed 1

#

You could increase or decrease it slightly depending on the relative density you expect from your object

#

🤔 I don't know you may end up with weird results elsewhere

#

show it to friends around you, see if they find the floating too quick too

gray falcon
#

this is one thing, its very unintuative thats for sure

supple sparrow
#

Oh I see. speed looks okay in water but once in the air not so much 🙂

gray falcon
#

yea haha

supple sparrow
#

Yeah increase mass then

#

or square the gravity force

gray falcon
#

I also have quite low drag, as I thought it would affect the handling in the water. Maybe I should up that too

supple sparrow
#

(outside of buoyancy - when in the air)

#

Yeah focus on fixing the feeling in the air, not in water

gray falcon
#

i do have an "isAirborne" bool available already, can maybe fiddle with that

gray falcon
#

added 5 tons on, seemed to help a lot

grizzled root
#

hi can someone tell me why the player still sticks to the platform even though i've added a no friction material?

desert wave
grizzled root
#

@desert wave force as in..? they have the rigidbody component and the no friction material attached

desert wave
#

And does one of them have gravity?

#

Or do one of them is being pushed against the other?

grizzled root
#

gimme a sec i'll show u how the game works

desert wave
#

Ok

#

Can you do the bug

grizzled root
#

it should just fall but it sticks to the platform even after lifting the right arrow key

desert wave
#

Are you on windows?

grizzled root
#

yeah im using a windows laptop, if that's what ur asking?

desert wave
#

Hit windows + G

#

It will show a bar in which you can record your screen better

#

But going back how do you move your character

grizzled root
#

by using the arrow keys

desert wave
#

With Addforce, velocity or translate?

grizzled root
#
{
    private Rigidbody rb;
    private bool JumpKeyWasPressed;
    private float HorizontalInput;
    [SerializeField] private Transform groundCheckTransform; 

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {

        if (Input.GetKeyDown(KeyCode.Space) == true)
        {
            JumpKeyWasPressed = true;
        }

        HorizontalInput = Input.GetAxis("Horizontal");
    }

    private void FixedUpdate()
    {
        rb.velocity = new Vector3(HorizontalInput, rb.velocity.y, 0);

        if (Physics.OverlapSphere(groundCheckTransform.position, 0.1f).Length == 1)
        {
            return;
        }

        if (JumpKeyWasPressed)
        {
            rb.AddForce(Vector3.up * 6, ForceMode.VelocityChange);
            JumpKeyWasPressed = false;
        }
    }
}
#

this is the code im using

desert wave
grizzled root
#

it's already been added

supple sparrow
#

So it gets stuck only when you fall on the edge of the platform ?

grizzled root
#

yeah, instead of sliding down

supple sparrow
#

uhm probs because the overlapsphere

#

you can detect the ground diagonally

#

and even from the side

#

so you can stick to it like spiderman

grizzled root
#

i don't quite get it..

supple sparrow
#

Physics.OverlapSphere(groundCheckTransform.position, 0.1f)

grizzled root
#

what do i change/add?

supple sparrow
#

it would even stick you to the bottom of the platform if you jumped to it from below 🙂

#

I would probably try to do 1 raycast down. Or 2, one at each feet eventually

grizzled root
#

but why does the no friction material have no effect

supple sparrow
#

good question

#

i'm not used to them 😅

grizzled root
#

ah it's alright, thanks anyway :)

supple sparrow
#

maybe show the rb and collider of the player

grizzled root
supple sparrow
#

yeah at first I thought you returned too early because of the overlapsphere but it's just jump code after that

#

Shooting in the dark here, can you try with a Friction combine of zero on the NoFriction mat ?

#

maybe the average with the platform prevents it from sliding 🤷‍♂️

grizzled root
supple sparrow
#

i wanted to say mutliply

#

damn i'm tired

#

but minmum should be okay too in fact

grizzled root
#

didnt work,,

supple sparrow
#

Uhm. capsule mesh of the collider seems right... I have no clue right now what is the problem :p

#

collider f the platform is just a box i assume

warm helm
#

hiya, i have a question; i'm trying to make a one-way 3D platform (similar to smash bros) but i cannot get it to work. any ideas?

inner thistle
#

That's a bit too vague

#

Is there some specific problem or...?

warm helm
#

like, i got it as far as being able to jump through the platform and land on the top, but i cannot make the "hold x key to go down" part to work

marble mural
#

Hey, I need Polygon colliders at all of the street walls. Is there any way to do this quicker than placing them all manually?

spiral tulip
#

if not, when you add a polygon collider, it should automatically detect the shape if it's 2d but otherwise you'll have to place them manually unfortunately

random sedge
#

Hoping this is the right place to post this, I haven't been on this discord in a looooong time

#

So

#

I'm trying to get this crouch mechanic working

#

And when the player crouches, the shrink, and all looks to be well. The capsule from the first person controller component shrinks accordingly

#

Nevertheless

#

I can't fit under the slab!

#

And I don't get it at all

ashen tangle
#

Hey guys, I'm trying to make a system where a player (rigidbody) can stand on a boat (rigidbody) and he can move freely around it and not fall off it it starts moving. The solutions online suggest making the player a child of the platform only when on top. This doesn't work as they are both rigidbodies. How can I make this work?

#

3D btw

gentle cape
#

See the video below for the weird behaviors.
To be clear it doesn't do this all the time, more like in 10-15% of the cases.

Normally the discs bounce of each other and other collision objects(like the pillars) and move in an equal or opposite direction.

Weird behavior includes:

discs being clued to the ground and not budging or just flipping weirdly and getting pushed through the ground collider
Instead of bouncing off various collision objects and going into an opposite and equal direction ... it just pushes through the initial direction and does not bounce off of collision objects but rather , it pushes around them

I was wondering if anyone knew where or how this behavior gets influenced or defined ...because I don't know where to look anymore
https://youtu.be/HA60zLETNc4

desert wave
desert wave
craggy cave
#

how can i transform a collider? i want it to be on the human model yknow

alpine delta
# random sedge

I am 99% sure you are just resizing only mesh of player not its collider

limpid hornet
#

At what point should I consider creating a simpler mesh for a MeshCollider?

copper sentinel
#

why capsule collider for player is a good idea? the more i work with character controller the more i get frustrated

weak sable
#

I have a question, how can I look at the havok debugger?

#

I wanted to play with it but I can’t find out how to access the debugger

sweet snow
spiral tulip
#

i think both objects involved in the collision have to have a rigidbody as well as a collider so try that and if it still doesn't work check the normals on both meshes

#

also i vaguely remember reading something about mesh colliders not being allowed to collide with other mesh colliders but that might be wrong idk

teal harness
#

can anyone help me with cloth physics? its like colliding with a collider thats not even there

limpid vigil
fringe heron
#

wow, setting step offset to 0 worked

#

but... with step offset with value 0 I am still able to climb stairs

#

why?

gentle cape
# desert wave It doesn’t seem that hard to solve can you show us more, like how is the force a...

I wish it wasn't hard to solve. 😉

The force is applied by taking a dragdistance and apply that as a force multiplier, I use Forcemode.Impulse.
The collision detection is set to continuous dynamic and I have made and applied a physics material.

On this material I have set Dynamic and static friction to 0.475 and bounciness to 1 ...friction combine to minimum and bounce combine to Multiply

I have frozen Position X on the rigid body and the rotations of X & Z

desert wave
gentle cape
# desert wave what are the constraints for? can you freeze position on the y?

Well there is a setting that says it constrains things on y ...not sure if it really works though.... and I constrained y because otherwise the discs fly into outer space ... I fixed rotations because someone suggested that the discs might tip on collision ...but it doesn't really make a difference .... even physics settings don't do anything noticable

desert wave
#

well you need to discover what causes the error, try only 1 constraints

#

or different settings and stuff like that

#

if its the velocity or your pc

timid dove
#

you should combine all of your cc.Move calls into one

fringe heron
#

and after

#

for y

#

in different functions

timid dove
fringe heron
#

ok, thanks, I will try it out

timid dove
fringe heron
#

thanks ❤️

#

2min

#

:/ I could not doit, can you help?

#

@timid dove

timid dove
#

like I said you just have to add those vectors together and call Move one time with the result

fringe heron
#

I added _velocity vector to the moveDir

#

but

#

It didn't work well

timid dove
#

not _velocity and moveDir

#

those entire expressions

fringe heron
#
_velocity * Time.deltaTime + (moveDir) * _currentSpeed * Time.deltaTime

?

timid dove
#

yes that looks more correct

#

you can also simplify a bit like

(_velocity + (moveDir * _currentSpeed)) * Time.deltaTime```
fringe heron
#

I did this

#

😄 Thanks a lot

#

it worked! <

#

❤️

buoyant inlet
#

anyone know how i can make a wall that only the player can walk through, and no other 3d objects can get past

coarse veldt
desert wave
#

theres a place for physics

ebon zephyr
#

Hello, is there a way to share colliders between different physics scenes? I have a big world and copying everything to every scene seems to be wrong

supple sparrow
#

Make a Prefab from them, then Instantiate in each scene ?

ebon zephyr
#

the problem is that the collider i want scenes to interact with is a massive multi object thing, copying it 16 times will be too slow

#

terrain, tons of roads

arctic marsh
#

Not sure what your setup is, why do you have the same world in different scenes? Why not use one scene and lay the gameplay as a dynamic object on top?

ebon zephyr
#

The setup is just a big world scene and small scenes dedicated for physics only that i want to step

thorn geode
#

Y’all ain’t no nothing till you make soft body physics with a swarm of pixel art monkeys

desert wave
thorn geode
#

or maybe video hasn’t loaded fully for u

#

It’s like a thick syrup of monkey

desert wave
midnight glade
#

Does anyone know why my collision stops working whenever I add a Rigidbody to my Player, but when I remove the Rigidbody and only keep the Box collider it works again? The collision is specifically with the particle system

timid dove
midnight glade
#

The particle system works as a gun firing particles as bullets, but the collision is only registered when it hits the player with a Box collider, but as soon as a ridigbody is added it stops detecting it

#

I did "solve" it with a workaround by adding an empty object as a child and attached another Box collider + Rigidbody so I can register collisions with other colliders in the world, but the combo of both those components is what the particle collision has something against apparently

#

Feels very weird

#

Seems like this dude had a similar issue, though never addressed

coarse veldt
stuck bay
#

Hello i have a question about rigidbodies and i think best way to explain my question is by giving examples(because my english isnt that great). Lets say that i have an object that i want to catapult towards a location. How can i calculate the force to make sure that object hits its target?

timid dove
#

you would use those equations and plug in the desired distance, initial angle, max height, target height, etc.. and solve for initial velocity

stuck bay
#

thank you very very much! i didn't even know what to look for while i was doing research!

alpine delta
#

There is a way to disable/enable all physics in game? I need to enable physics when player initial spawn event is called (mp game)

timid dove
alpine delta
timid dove
#

of course

alpine delta
#

yeah, thank you so much man

small tendon
#

hi,
i have gameobject that contains some colliders as chid ...
so, does OnCollsionEnter() working for that gameobject or have to this gameobject have a collider itself??

shell adder
timid dove
#

as long as the parent has a Rigidbody

molten island
#

not sure if this is actually a physics issue but i just have a sphere falling freely then sliding down a track. i have set the main camera to follow the ball via position and look at constraints. when i use either of the two constraints by itself, everything is smooth, but when i activate both constraints the ball/camera appears to jitter severely

tender gulch
molten island
tender gulch
molten island
#

tried both interpolate and extrapolate and it still jitters

#

ball movement appears smooth when camera is in static position

tender gulch
molten island
#

just gravity via rigidbody

hard furnace
#

why doesnt transform.position work while physics are being applied?

tender gulch
molten island
tender gulch
molten island
#

no jitter though it creates the need to lock rotation as the camera spins with the ball

#

not rotation sorry but

#

the ball spinning changes the position of the camera globally (but not relative to the ball), like it orbits it

tender gulch
molten island
#

yeah, but the camera moves regardless of the constraints when it is child of ball

tender gulch
#

Yeah, I get that. What I'm asking is whether there's anything else on the ball.

#

or the camera

vivid salmon
#

Hey guys!

Anyone knows the right direction to implement custom collision solving to heightmaps? Mesh-based collisions won't work because I have a lot of problems with rigidbodies boucing off the edges, also I want something more smooth without increasing any kind of resolution, just pure mathematics.

I think I have something, if a point of the rigidbody is bellow the terrain height in (x,z) I move the rigidbody up based on this difference, but sometimes the rigidbody would still be bellow the surface because of some kind of async between rigidbody physics update and FixedUpdate, I'm not sure, but every frame the point would still be bellow the surface by a tiny amount.

Also, I'm using Rigidbody's position and rotation instead of transform, because it seens that every physics frame only the rigidbody transform is updated and then it applies to transform every visual frame, I think.

So what's the correct way to threshold a rigidbody point position so that it always will be above the threshold every physics frame?

molten island
#

ball is just rigidbody, camera is just the two constraints

hard furnace
#

@tender gulch if I have a force applied to my player or if they are moving the transform.position runs but the player returns to their position from before it did

tender gulch
tender gulch
hard furnace
#

@tender gulch how do I work around that?

molten island
tender gulch
tender gulch
molten island
#

my best guess is that the position offset it is using is local to the ball and not global, and im not sure how to fix that

hard furnace
#

@tender gulch I want to teleport my player to a previously saved location

tender gulch
hard furnace
#

@tender gulch the jump is based on physics because I don't know how to do gravity without physics and cant find a tutorial

tender gulch
molten island
#

yeah i can uncheck rotation but the isnt the issue. unchecking position just stops it from moving at all ofc. the problem is that it is staying in the fixed place relative to the balls local space, not the world space. so when the ball rotates and its local axis change direction, the offset position moves

hard furnace
#

the only reason I know the player teleports at all is because of a debug.log but immediately after the go to where they where before the position change

tender gulch
tender gulch
hard furnace
#

@tender gulch like this

tender gulch
#

So it's not physics at all!

#

It's a character controller

hard furnace
#

the jump is

tender gulch
#

This is via the controller too!

hard furnace
#

it is?

tender gulch
#

controller.Move

hard furnace
#

oh. well that's good to know.

tender gulch
#

I don't remember why, but yeah, CharacterController has that issue, that it overrides transform position.

hard furnace
#

@tender gulch ok thx for the info i'll scour the internet thank you for your time.

tender gulch
#

@hard furnace share the code where you teleport it too.

hard furnace
molten island
tender gulch
hard furnace
#

@tender gulch at the top of Update

#

I've also tried calling it at the bottom

tender gulch
#

Oh, didn't notice it

tender gulch
hard furnace
#

no, I think what you said was right about the character controller having it's own position tracker was true.

tender gulch
hard furnace
#

@tender gulch thank you

grave pagoda
#

hey guys i need some help applying some spring bones to my model can anyone help me please

sinful marsh
#

Say your problem, people will respond to that

wise wind
#

Hi im trying to sync a player models position to a physics objects velocity but I want to keep the player model always facing up and only rotating around the y axis (Hope that makes sense) This is the code I have currently (This is in Update) but it rotates around other axis not just Y

        //Set position of player model to the same as the Physics ball
        transform.position = new Vector3(ballRB.transform.position.x, ballRB.transform.position.y - 0.25f, ballRB.transform.position.z);

        // Rotate player direction to direction of travel
        if (ballRB.velocity.magnitude >= 0.2f)
        {
            Quaternion dir = Quaternion.LookRotation(ballRB.velocity, Vector3.up);
            Quaternion slerp = Quaternion.Slerp(transform.rotation, dir, ballRB.velocity.magnitude * bounceTurnSpeed * Time.deltaTime);
            transform.rotation = slerp;
        }
grave pagoda
timid dove
#
Vector3 velocity = ballRB.velocity;
Vector3 projectedVelocity = Vector3.ProjectOnPlane(velocity, Vector3.up);
Quaternion dir = Quaternion.LookRotation(projectedVelocity, Vector3.up);
still stone
#

anyone know how I can stop the player/capsule from being brought upwards by the ball? i'm just using addforce Acceleration on the x&z plane

timid dove
still stone
timid dove
#

in effect the ball is also a ramp right

#

but it seems weird to me it's flying upwards that much

still stone
#

i don't see how when the pill collider shouldn't be stepping onto the ball

timid dove
#

can you show your code?

still stone
#
    void FixedUpdate()
    {
        //CancelUpwardVelocity();
        if (!mouseDown)
            return;
        destination.y = transform.position.y;
        targetVel = (destination - transform.position);
        targetVel = speed * targetVel * Time.fixedDeltaTime;
        var currVel = playerRb.velocity;
        currVel.y = 0;
        var diff = targetVel - currVel;
        var force = diff / Time.fixedDeltaTime;
        if (force.y > 0)
            Debug.Log("FUCK");
        playerRb.AddForce(force, ForceMode.Acceleration);
    }
#

somehow the angular velocity or the torque of the ball is bringing up the player

timid dove
#

can you show more code?

#

How is destination being set?

still stone
#

it shouldn't matter because i am taking out the y component in destination and in targetVel

#

i check if there is any upwards force being done, but I don't get that debug message

#

so the upwards force that is being generated by in-house unity physics

timid dove
#

yeah it's probably not your force that's pushing it up it's the collision

#

and/or friction

#

if the ball rotates there may be a friction force pushing your player up a bit

still stone
#

i have added a physical mat on the capsule/player that gives it 0 static & dynamic friction, same issue

timid dove
#

with friction combine set to minimum?

still stone
#

no, let me see

#

i think that fixed it lol

#

why would this be a thing when i gave it 0 friction?

shell adder
#

nice

timid dove
#

so your player has 0, the ball has the default which is nonzero

#

the average is nonzero

still stone
#

ah so if it collides with anything that has friction then it will average between my 0 friction and something's 1 friction lets say, giving the ball 0.5 friction?

#

now how do I raycast at the capsule/player feet to a wall?

#

i don't know what would be the best way getting the vector from feet location

#

besides using -rigidbody.y/2, which i probably will do i guess

#

i need to remove addforce into walls, so i will project onto a plane and have it slide against all steps/walls

shell adder
still stone
#

only problem is utilizing the right raycast distance, i assume i need to somehow get the thickness of my pill collider. but i don't see how that can work with dynamic players like rotated rectangles

shell adder
#

capsule colliders have the radius property

still stone
#

i'm going to be using multiple box colliders, like leaning forward with arms outstretched

#

once i learn how to 3d model lol

still stone
shell adder
still stone
#

oh, normalized. i was reading normal vector

shell adder
still stone
#

i'm sure the ground will always be the closest point

shell adder
#

closest point on the player's collider

#

if the case is that the player has an arm sticking out then the closest point will be on that arm

still stone
#

i imagine my colliders will look like this

#

maybe even a bunch of pill colliders

#

so the main body will be a big pill collider where the ground should be the closest point

shell adder
#

so in that case the red square is the far point, which is determined by the red arrow which is the direction of movement, and the end of the green line is the closest point

#

then raycasting from that green point will determine if the player is going to collide with a wall

still stone
#

the green arrow is the velocity of the player, wouldn't the red circle be the closest point for bounds vs the orange circle?

#

or is it that using ClosestPoint with the direction vector will ignore the ground completely because there's no y component on the vector?

shell adder
#

so it will be somewhere around the edge of the orange yes

still stone
#

on the capsule collider, right?

shell adder
#

this would be easier to do if it was all one collider, so either that or one mesh collider

#

if it was separate colliders then you would have to run this check on each one, and see which is closest to the far point (the green circle)

still stone
#

you can't fuse colliders?

shell adder
#

in 3d i don't think so

#

but there are mesh colliders

still stone
#

i imagine the mesh collider will be tied to my character's animation

#

which i want to ignore and have non animated colliders

shell adder
#

the mesh itself and the mesh collider can be different

#

like the renderer can be animated but the collider stay the same

still stone
#

hmmm

shell adder
#

alternatively, and much simpler, is ontriggerenter

#

but where's the fun in that

still stone
shell adder
still stone
#

i'll test it out and see 😄

#

thanks for the help btw

shell adder
#

np

tender gulch
#

each collider in a compound collider would have it's own bounds.

still stone
#

is there a way to make friction specific between 2 rigid bodies but not change the overall friction?

timid dove
#

and have normal separate colliders for everything else

still stone
still stone
#

thanks

humble timber
#

@here Hey there, I am working on a movement system for my game and I need help with implementing a good system for sliding on slopes with character controller. I want to create a realistic sliding system in which when you jump forward with an initial speed to a slope, you will slowly change direction to the ground. In my current system, when I jump on a slope, the player immediately changes direction to the ground, which is something I don't want. I will appreciate any help.

still stone
#

how can I check if my player is grounded? this doesn't work because it's a null reference and i'm sure this won't work with floors

    private void OnCollisionEnter(Collision collision)
    {
        if (Vector3.Dot(collision.rigidbody.position, transform.position) == 0)
            grounded = true;
    }
#

i'm thinking of raycast, but it's not perfect because the collider/rigidbody can be bigger than the playerCollision.size.y/2 used for raycast

#

I'm trying to stop the playing for addforcing into a wall using friction to stop themselves from falling. i want friction but not anti-gravity friction so i need to do a ground check

still stone
#

i feel that this is just too hackish

return Physics.Raycast(transform.position, Vector3.down, playerCollider.bounds.extents.y * 1.1f); // 110%
shell adder
still stone
#

am I not able to get the contact point in O(1) for OnCollisionEnter?

#

afaik you need to for loop through Physics.OverlapSphere

#

i assume it would be the last collision in the list so collision.contacts[collision.contacts.length-1] could be the way

shell adder
#

so i don't think iterating through it is necessary

still stone
#

i'm not using ground layermask, seems like a hassle

shell adder
#

but it's a ground check

#

all you need is to detect the ground

still stone
#

but i want dynamic physics

#

where dynamic things are happening like maybe a piston hits you up, or you land on other balls

#

or you're on a vehicle moving on the rooftop

shell adder
still stone
#

pass in layers you want to overlap?

#

i mainly need a boolean check for when to stop player control when in the air

shell adder
#

no need to iterate through the array

still stone
#

wouldn't that be expensive to check per oncollisionexit?

#

since you're constructing a list and adding to the list by iterating through all game objects that have this layer?

shell adder
#

the nonalloc version is like the normal but generates no garbage

#

so it uses less resources

still stone
#

why not just do collision.contacts[collision.contacts.length-1] for OnCollisionEnter, then check if the dot product is 0 or close to 0?

#

i'll see if it works, if not i'll try the nonalloc

shell adder
#

yeah sure

still stone
#

this kind of works but not very well

        var contacts = collision.contacts;
        var dir = (contacts[contacts.Length - 1].point - transform.position).normalized;
        var dot = Vector3.Dot(dir, Vector3.down);
        Debug.Log($"dot: {dot}, dir: {dir}, down: {Vector3.down}");
        Debug.DrawRay(transform.position, dir, Color.red, 50);
        grounded =  dot > 0.9;
#

ah whatever, i'll just use layers

    void OnCollisionExit(Collision collision)
    {
        if (!grounded)
            return;
        grounded = collision.gameObject.layer == 9;
        //grounded = IsGrounded();
    }
#

though the exit part breaks

still stone
shell adder
still stone
#

you're not using your collider instead of this sphere hitbox/collider

shell adder
#

this sphere is if you want to check below the player by a certain amount

still stone
#

yeah i'll probably do what you're saying, though I think the sphere needs have a smaller radius at your feet so it doesn't come into contact with walls that are ground layer by accident

#

so your collider blocks the sphere at your feet from touching walls

shell adder
#

if it's a capsule collider then you can set the radius of the sphere to be the capsule's radius minus a little

#

just to be safe

still stone
#

are physics and player controllers the hardest part of making a game?

#

because i'm astonished how many issues/bugs there are with this lol

bleak umbra
#

physics player controllers are always glitchy, thats why "everybody" builds custom controllers with kinematic physics

shell adder
#

some people find it easy, some don't

#

it also depends on how complex it is

still stone
#

well i never took any gamedev courses or read books on it

#

so i don't know how to handle a lot of things properly or its physics

bleak umbra
#

its easiest to not use "realistic" physics at all for gameplay

still stone
#

i imagine if i actually took gamedev courses in my comp sci program, i would probably understand how to deal with a lot of these issues i'm having lol

bleak umbra
#

maybe you can draw some neat space filling curves or rotate a camera, but other than that... this is a learn-for-your-self type of thing

still stone
#

i.e. Physics.OverlapSphereNonAlloc(bottom, radius, cols, 9); isn't picking up layer 9 even though it should be

#

or am I supposed to do 1 << 9?

#

oh that was it...

still stone
#

Still having issues trying to stop adding force if the player is stuck on something. Capsule/player flings off steps/walls too easily

#

i thought having a raycast done at a lower position would help but then the raycast doesn't register because it's in the ground

spiral tulip
#

tag the wall and check in OnCollisionEnter

still stone
#

walls can be ground, so i can't use tags

spiral tulip
#

wdym walls can be ground

still stone
#

if you see the ramp in the video, that ramp can be wall + ground

spiral tulip
#

then just don't tag it as wall

#

tag it as ground

still stone
#

but then it will still fling up

spiral tulip
#

hmm not really sure what you mean

#

i think i misunderstood the flinging thing

still stone
#

it shows in the vid when i make the capsule move into the ramp at the bottom, it gets caught on the ramp and the extreme horizontal force forces it to fling up because of the capsule collider getting over the step

torpid epoch
#

I just realized that this may be a better thread for my problem than #archived-code-general - I have a wall that's supposed to pivot around a point. I used a hinge joint for this. It spins properly when the transform rotation is set to 0 or 180, but if I try to set the transform to 90 or 270 it gets stuck. Any ideas?

#

Actually looks like setting the transform rotation to anything other than 0 or 180 breaks it

still stone
#

I made it so my capsule slides along walls, but when the vector reaches a corner then it stops working as the raycast isn't detecting a wall anymore. Any advice?

#

i have no way for sure checking if my capsule is colliding with a wall in my function unless I raycast all around me and check if i'm colliding...

#

at this point i'm considering of having an array of collisions that i update with OnCollisionExit/Enter

tender gulch
still stone
tender gulch
still stone
#

but then i'm reliant on using a CapsuleCollider

#

maybe a SphereCast but providing the largest boundary?

tender gulch
#

I guess a sphere cast could do as well, anything that has a radius and not just pin point.

#

I still don't know what you're trying to achieve, so I might be wrong.

still stone
#

the problem is that i don't want the capsule/player to fling around corners of walls or slingshot off steps like the bottom of that ramp

#

because there's a large force being applied by clicking and dragging your mouse around which tells the capsule where to go

#

so if you apply a huge horizontal force and the capsule hits a speed bump, it will fly upwards

#

so i need a way to check for speedbumps and corners of walls so the sling shotting doesn't happen

#

i like the control scheme as is, but i don't like this sling-shotting/flinging coming from the collider getting stuck on the environment

#

i feel that the corners of walls can be fixable, but the speed bump bug is impossible because if you raycast so close to the ground then the raycast will hit the floor itself instead of the speedbump

#

err i cropped i video, so this is the exact moment

#

maybe playing around SphereCast will fix it...

#

but i thought this is a common issue with rigidbody player controllers so someone might know how to fix it

tender gulch
#

Maybe detect the ground level in direct proximity to the capsule, instead of where the mouse points?

tender gulch
still stone
#

also, aren't FPS games rigidbody player controller based? Why don't they have these issues?

tender gulch
# still stone could you elaborate?

Neverminded. I assumed something about your implementation that's probably not the way it is.
What could be relevant though is that you increase the force the farther away the pointer is, right?

tender gulch
still stone
#

What could be relevant though is that you increase the force the farther away the pointer is, right?
I do, I find the controls become very response and intuitive given that there are no obstacles that glitch it

#

navmesh agent?

tender gulch
tender gulch
still stone
#

i never learned it in the junior programmer pathway

#

i'm new to gamedev, i just know how to program

tender gulch
still stone
#

if that's for AI pathfinding why would that help with player controllers?

tender gulch
still stone
tender gulch
still stone
#

hmm

#

i might do that if this keeps becoming a pain

tender gulch
#

I think it's possible to configure your controller if you take into account the things I mentioned.

still stone
#

even if i clamp the force, the unity engine will still treat speedbump like a launch ramp converting the horizontal force into an upward trajectory. it just won't slingshot up as high

tender gulch
#

Limit the max force you apply based on the current velocity of the character.

#

if it's small enough, it won't be able to go up. I think

#

another way, is not using a capsule but a box for example

still stone
#

in what manner? force * playerVelocity.magnitude?

tender gulch
#

Yeah. And maybe use a curve too, if you want it to be more responsive.

still stone
#

a curve? so a log function?

tender gulch
tender gulch
still stone
#

i don't understand what you mean by curve. you mean to configure the acceleration?

tender gulch
#

force = maxForce * curve.Evaluate(velocity/maxVelocity);

still stone
#

i mean you could do a squareroot function, but squareroot is expensive for computers

tender gulch
#

velocity/maxVelocity gives you a value from 0 to 1. You can use a curve to remap the value in a desired way.

tender gulch
#

like this

still stone
#

that's a component? I'm not finding it

tender gulch
#

It's not a component. It's a unity class that can be serialized

#

AnimationCurve

still stone
#

woah

#

damn, all this is really helpful

tender gulch
#

Yeah, it can be pretty handy at times.

still stone
#

i think the sphereraycast + velocity checks should fix mostly everything

tender gulch
#

Perhaps.

still stone
#

@tender gulch i think the velocity limiter helped, though it's still launching over speed bumps

desert wave
#

You can try checking if it can go over that

#

With raycasts

still stone
#

yeah last thing to do, but i'll save it for tomorrow as it's 2 am here

#

plus i gotta actually study for some job interviews i got coming up

still stone
upper sparrow
#

anyone have any advice on how to add controls to balance a 2d capsule, to push it left and right, on a flat surface as challenge?

still stone
upper sparrow
#

ill try that and get back to you

#

dont know if im doing it wrong, but it still isnt working

#

btw im also using a hinge joint as the balance point

spiral tulip
# upper sparrow

did you debug.log the value of horiz in Update to make sure you're not multiplying by 0?

upper sparrow
#

yeah

#

it changes from 1 to -1 depending on the keys i press

spiral tulip
#

and did you debug.log the value of moveSpeed in FixedUpdate

upper sparrow
#

yeah also from -20 to 20

spiral tulip
#

and debug.log the value of rBody.velocity at the end of FixedUpdate?

upper sparrow
#

ill try that

#

its staying at 0

#

but does addforce directly affect velocity?

spiral tulip
#

congratulations you've narrowed down where the error is, that's 80% of solving the problem 👍

spiral tulip
upper sparrow
#

oh

spiral tulip
#

next step is to debug.log a right before rBody.AddForce

#

to make sure you're passing the right vector AddForce

upper sparrow
#

it stays stuck at 0.4,0.0 and -0.4,00 depending on the arrow key i press

spiral tulip
#

is that what you want?

#

wait hang on lmao

#

that feels way too small

upper sparrow
#

yeah i would suppose it should be greater

spiral tulip
#

try multiplying it by like 1000 or something before passing it to AddForce and see if it moves

#

sometimes it is actually moving, you just can't tell bc the force is too small that happens to me a lot

desert wave
#

try other force methods

#

if you get a different type of movement

upper sparrow
#

it stayed the same when i changed to speedfactor to 1000

spiral tulip
#

hmm

upper sparrow
#

but when i removed the deltatime multiplication it kinda worked

spiral tulip
#

maybe the issue is friction with other bodies?

#

oh ok

#

maybe make speedfactor like 1 million lmao

#

seems hacky but whatever works, i guess

upper sparrow
#

oddly enough it seems mulitplying it by Time.deltaTime just totally restricts it to 0.4

spiral tulip
#

weird

desert wave
#

and btw why do you use time.deltaTime?
use Force.Acceleration

spiral tulip
#

using Time.deltaTime makes the movement the same speed across all computers regardless of cpu speed

desert wave
spiral tulip
#

in that case definitely don't use time.deltatime

upper sparrow
desert wave
spiral tulip
upper sparrow
#

i think i can only use ForceMode2D

#

cuz im using rigidbody2d

#

and there doesnt seem to be a ForcceMode2D.Acceleration

desert wave
#

well do rb.Addforce(a*rb.mass);

upper sparrow
#

thanks, seems to be working well without the deltaTime

#

ill just mess with variables to control how fast i want it to rotate

desert wave
#

np, good luck

lilac lintel
#

Anyone know how I can prevent my particle system (shield bubble around the character) from moving after a collision? The Transform is 0,0,0 after collision but the mesh keeps moving. If I stop/play it's always reset back to the original position.

spiral tulip
#

oh wait i see it

#

simulation space

#

in the first menu

lilac lintel
#

yea i tried that, i actually wanted to use custom and set to the player transform but the bounding sphere is totally wrong then. Either way none of those options seems to have any effect 😦

#

i also tried playing with Limit Velocity over Lifetime... also seems to have no effect.

#

also collision > dampen etc seem to have no effect

spiral tulip
#

oh huh

lilac lintel
#

crazy right? 😄

spiral tulip
#

did you try making the particle system a parent of the player

#

ik that seems weird but it could work 🤷

lilac lintel
#

no but it does work with custom to some degree, its just that the bounding sphere is a bit off. but its ok i dont need it to be stuck to the player, its fine if it's in a fixed position, probably better for GPU in VR anyways 😉

spiral tulip
#

ok well you decide what works best for your project 👍

lilac lintel
#

i just need it to not move when something collides with it 😦

spiral tulip
#

you could remove the collider

#

what do you need the collider for? is it completely necessary?

lilac lintel
#

yeah its a shield, to block stuff from hitting the player

spiral tulip
#

i see

#

you could make it a trigger and manually remove or repel objects in OnTriggerEnter

lilac lintel
#

im also reflecting stuff OnParticleCollision()

spiral tulip
#

idk if it's possible to make particle colliders a trigger but if it is, try that

#

then reflect stuff in OnParticleTrigger or whatever the equivalent is

lilac lintel
#

i basically am doing that already 🙂

#

repelling stuff with OnParticleCollision()

spiral tulip
#

yeah but the difference is that triggers don't physically collide with anything

#

so you could have the same effect without the system getting pushed by other bodies

lilac lintel
#

i'll have to investigate that, dunno if i can get particle system triggers to work the same but its a good tip, cheers 🙂

spiral tulip
#

ok gl!

hardy tulip
#

should I use update or fixed update for applying a force on a rigid body player when the wasd keys are pressed?

shell adder
hardy tulip
#

i see

#

thanks

delicate birch
#

hi guys, I had a problem on meshcolliders, my terrain is made by meshcolliders , when my character(with rigibody) walking on it(use add force), it bumps a little on the seam of meshcolliders, even it is absolutly flat. both my terrain and character have physic material with no fiction ot bounciness. any way to fix this?

molten island
#

so i have a rigidbody2d the starts frozen on the y axis, then the y axis is unfrozen (constraints set to none). now, it should be falling at this point, but it stays until interact with the constraints in the inspector (doesn't matter which one. i could tick freeze rotation and suddenly it starts falling)

molten island
vapid ore
jaunty star
jaunty star
still stone
#

anyone know how I can detect walls? I'm using this but the spherecast ends up in the middle of the wall sometimes and doesn't detect a wall...

Physics.SphereCast(bottom, playerCollider.bounds.extents.x*1.1f, rayVec, out hitData, rayDist, ~(1 << 6 & 1 << 8))
spiral tulip
still stone
spiral tulip
#

oh right i remember that

#

you could do a 4-way raycast that might work better than a spherecast

still stone
#

oh wow, i think my mic below my computer picked up electromagnetic interference from my GPU

spiral tulip
#

yeah 4 raycasts: in front, behind, right, and left

still stone
#

i mean what i'm doing would serve the same purpose, but i notice that if the spherecast location is inside the wall then it doesn't detect a wall

Physics.SphereCast(bottom, playerCollider.bounds.extents.x*1.1f, rayVec, out hitData, rayDist, ~(1 << 6 & 1 << 8))
spiral tulip
#

if you have colliders on the walls and the player, you shouldn't go into the wall

#

you could make a second slightly larger player collider to serve as a buffer for the walls only

#

and set layer collisions off for other layers

still stone
#

i mean they already don't go into the wall, not sure what you mean

spiral tulip
#

if you don't go into the wall, why is the spherecast inside the wall

#

just cast it from the player's position and it won't

still stone
#

i think this is the spherecast, i tried using Gizmo drawsphere but this is what the spherecast should look like:

spiral tulip
#

looks like its origin is outside the wall so what's the issue?

still stone
#

spherecast isn't detecting a wall apparently

spiral tulip
#

try casting from the player's position

#

it doesn't look like it's at the player's position

still stone
#

it's at the bottom of the player's "feet" but i had to give it a distance of 0.1f because i can't give a distance 0 as it doesn't work

#

Here's the vid of the issue, it has working wall sliding but when the player goes too fast into the wall then it doesn't work

#

maybe i need to make the spherecast radius smaller

spiral tulip
#

sure sounds like a good idea

#

also don't make it at the player's feet

#

you should cast from the center of the player

still stone
#

i think i'll just give up the the speed bump flinging issue

#

i'll just focus on polishing this wall sliding

#

i don't get why spherecast doesn't work if any part of the sphere is already inside an object because that means i can't spherecast with a radius of my player's height

spiral tulip
#

that can't be the issue

#

if the sphere wasn't touching anything it would never detect anything

#

there has to be a way to cast and have it collide with objects lol that's the whole point of it

timid dove
still stone
#

but how can i get the contact point and the normal of that?

#

since it returns Colliders

spiral tulip
#

do you need the contact point?

still stone
#

well i need to know where the OverlapSphere is touching and i want to calculate the normal of that

spiral tulip
#

but why do you need that

still stone
#

because i need to project my movement over the normal

spiral tulip
#

wut

still stone
timid dove
#

Start your spherecast at the top of the player's capsule and send it down

still stone
#

can OverlapSphere not provide the normal vector that i need? not sure if it's possible via the Collider objects it gives

timid dove
#

it doesn't provide any normals no

#

not sure how such a thing would make sense with overlapsphere

patent briar
#

Hello, I am creating a 2D game.
I got a problem with combining triggers and colliders. What I have are 3 layers: Unit (players and enemies), Environment (platforms) and Collectible. Environment are static objects, and both Units and Collectibles are objects with rigidbodies, having gravity, etc. So all 3 groups of objects need to have colliders to prevent Units and Collectible fall through Environment. However I also need to make Units "walk through" collectibles, if they cannot pick them. If I remove Unit/Collectible from Physics 2D matrix in project preferences, I also make them unable to recognize their triggers, so Units cant pick Collectibles onTriggerEnter2D.

Best solution would be if this Physics 2D matrix affected only colliders, but triggers would work for any layer (I can then resolve its effect myself), but that doesnt seem to be an option. Does anybody know the correct sollution for this? Pretty please? 🙂

timid dove
#

like have a non-trigger collider for the item so it doesn't fall through the ground, and then a separate trigger collider so the player can pick the item up

#

and have them on separate layers and set up the layer matrix appropriately

patent briar
timid dove
olive fog
#

Is there a way to make it so particles stop being affected by physics after a first collision?
I have snow particles falling on a slope and I want them to "stick", not slide down

icy kernel
#

Hey, im currently trying to implement wall jumping and its mostly implemented just it should bounce back the opposite way and its not doing that currently

#

the wall jump code is at the bottom

patent briar
timid dove
patent briar
hollow topaz
#

I have a question about Rigidbody constraints. I have an object that shouldn't move in the z axis (that works fine) and shouldn't rotate on the x axis (doesn't work). I don't understand because if the game is running and I enable constraint on the y rotation then the object stops rotating on both but when I disable the Y rotation constraint both remain constrained. Any Ideas?

vapid ore
timid dove
humble timber
stuck bay
#

hey i have some problem with ontrigger. its just not detecting ALL of my collisions when they happen to fast

#

is that because of some other scripts that are taking to long to process, or is it due to physics settings, or is untrigger unstable when it comes to fast objects?

vapid ore
#

my scripts where fine and now i get this error

stuck bay
#

so i used 10 colliders instead of one large scaled one and its working now. why is that a deal?

#

damn its still unstable with large stacks of collisions

hollow echo
#

Your project is using the new input system, your code is still using the old.

vapid ore
#

so how do i make it so they update

stuck bay
stuck bay
#

my problem is that ontriggerenter works but ontriggerexit is not working all the time

hollow echo
#

Weird

stuck bay
#

my timestep is already at 1/30 so i have higher collision detection

#

my projects is based on physics and i have tousands of colliders and rigidbodies in my scene

shell adder
stuck bay
stuck bay
#

and yea i tried to change the mode for one object, but not for both

stuck bay
stuck bay
shell adder
shell adder
#

or you can have some type of method where you occasionally do a spherecast to check if a collider is nearby, and if it is then turn on continuous / continuous speculative

#

that could save some colliders from being continuous if they're further away

lilac garden
#

https://answers.unity.com/questions/1189707/oncollisionenter-being-called-without-the-collider.html I have this issue where my player not-visually collides with objects behind it that are somewhat close. I have many OnTriggers and OnCollisions. What should be my next step to fix this issue and future proof this?

lilac garden
# lilac garden https://answers.unity.com/questions/1189707/oncollisionenter-being-called-withou...

Figured out that the Default Contact Offset was something like 1e-08. Documentation states: "Set the distance the collision detection
system uses to generate collision contacts. The value must be positive, and if set too close to zero, it can cause jitter. This is set to 0.01 by default. Colliders only generate collision contacts if their distance is less than the sum of their contact offset values". Changed to 0.01 and it's solved.

stuck bay
#

Can someone help me make my character sprint?
here is the script

weak gull
#

My character controller uses rigidbody.velocity to move the player, and whenever I move horizontally while on a moving platform (that is the player's parent while hes on top) the player stops moving with the parent. When I jump, again setting rigidbody.velocity, the player still moves with the platform. If the player stays still the moving platform moves the player without issue. The whole game takes place on a moving platform so it's kinda a big deal that it works, does anyone have any insight into what I'm doing wrong?

spiral tulip
weak gull
#

how do I make the player move with the platform then?

timid dove
#

that overwrites any velocity your character may have picked up from friction with the platform

weak gull
#

ok, I'll switch it to transform.translate or something I guess, thanks

hollow topaz
#

Are unity's rotational constraints not working for anyone? Because I am having trouble with them in my current project so I created a new project on the latest version of unity and it still doesn't constrain the rotation axis.

timid dove
timid dove
hollow topaz
# timid dove want to elaborate on what you're trying to do and how you're trying to do it?

I am creating a physic Ik character that is 3d but the game will be viewed 2d, this means the character should not rotation on the X axis. the problem I am having is the rotation constraint of the rigidbody of the parent body doesn't stop the character from rotating on that axis. plus I have tested a cube object in a new project and freezed the same x axis and it still doesn't freeze it.

timid dove
#

if any other code or components do it, it will not stop them

#

for example if your IK controller or other scripts do it, it will not stop that

hollow topaz
#

there is no code touching that axis

#

in this test project there is no code all together and the transform still shows the object is rotating on that axis

#

this is the test project, the x rotation axis is constrained and yet it still rotates

crisp panther
#

Hi all,
I was wondering,I have bunch of static colliders on multiple objects that I want to group together as a single entity so it can hold an OnCollision handler on a root object. The only way I know to do this is to add a kinematic rigidbody on the root object. However the doc says that static colliders are colliders with no rigidbody, so how are these static-but-not-quite colliders treated by the physics engine? Kinematic colliders, or Static colliders? Does it make any difference at all if I remove the static flag on those objects and just have them be a kinematic object that simply never moves?

supple sparrow
# hollow topaz

I see a star next to the filename. Could you save the scene, just to be sure ^^

timid dove
weak gull
stuck bay
#

i have 5 ghz cpu. its running at 300 fps on my machine

#

damn

#

i cant have realtime log from android on my pc. that is f**d

past grail
#

I want to rotate my object so that it is parallel to my collider all the time. I am emitting a ray and find the angle between hit.normal and myObject.transform.up. And how to rotate an object knowing this angle? Thanks

spiral tulip
#

if you want to rotate by that angle, do transform.Rotate(rotationYouCalculated);

vapid tree
#

Hey! I've been working on a player rigidbody controller and have come across an issue that I need to solve. The script uses rigidbody drag to slow down the players movement, however this means that when the player is jumping that their fall is slowed. Is there some way to make drag only effect x and z movement, or another way to slow down the player that doesn't use the rigidbody drag.

lilac garden
# vapid tree Hey! I've been working on a player rigidbody controller and have come across an ...

Drag How much air resistance affects the object when moving from forces. 0 means no air resistance, and infinity makes the object stop moving immediately.
Either you slow down player speed, increase gravity or exert an opposing force to the players velocity (times) a certain dragMultiplier. For example, you have an rb.velocity vector of (1,1,1), you can then rb.AddForce(-.5f, 0, -.5f).

vapid tree
#

Thanks for the help!

cobalt pilot
#

how do I make my rigidbody that has some joints attached to it, not be dragged down by objects that are hanging from those joints.

#

I still want to be able to set the velocity and stuff so can't make it kinematic

timid dove
viral ginkgo
#

@cobalt pilot how about you lerp the velocity instead

#

rb.velocity = Vector3.Lerp(rb.velocity, targetVelocity, 0.1f);

timid dove
viral ginkgo
#

I often do something like this to also make it more realistic via limiting the equilevent impulse per frame

Vector3 targetVelocity;
float maxImpulse;

Vector3 currentVelocity = rb.velocity;
Vector3 nextVelocity = Vector3.Lerp(currentVelocity, targetVelocity, 0.1f);
Vector3 delta = nextVelocity - currentVelocity;

rb.velocity = Vector3.clamp(delta, maxImpulse) + currentVelocity;
cobalt pilot
viral ginkgo
#

but looking more into it, thats probably not what you want

#

hmm actually yeah

#

if you do this velocity control on the main object

#

and it has a few other objects trying to drag it down

#

it should be able to maintain the altitude

cobalt pilot
#

isnt that just going to fall down sstill?

#

cuz it's set at 0.1f

#

so its almost the same as the original velocity

formal geode
#

Hi, for some reason my particle effect collision isnt working. It was working just fine one another one I was testing before.

#

It just phases through walls. Although it works with planes, but thats not what Iam going for

cobalt pilot
#

@viral ginkgo how does that work since it's not compensating for the force pulling it down is it?

viral ginkgo
#

lets say you want it to follow a trajectory

#

or a position

#

targetPosition

#

you set targetVelocity = targetPosition - transform.position

cobalt pilot
#

yes

viral ginkgo
#

and feed to my code

#

and you'll follow the position

#

it will follow a little below

#

like 1 meter maybe

#

and it will compansate

cobalt pilot
#

I see

#

Ill try it out, don't completely understand it yet

#

it does not compensate for the force and is still dragged down

timid dove
cobalt pilot
#

well if I have it follow that object then it will also just move with the object when dragged down no?

timid dove
#

there's no force pulling it down in what i described

cobalt pilot
#

ooooh I understand now

#

yes Ill try that

#

that makes it very stuttery for some reason

stuck bay
#

Hello, quick question, for some reason my instantiated object falls slower than a normal one and I have 0 idea as to why.

Vehicle =  Resources.Load<GameObject>(MenuScript.Vehicle);
        Instantiate(Vehicle, Hitbox.transform.position + new Vector3(0,10,0), Hitbox.transform.rotation);
timid dove
stuck bay
timid dove
#

Don'y you have some kind of movement script on the vehicle?

stuck bay
honest granite
#

i have a shoooting script spawning bullets with rigidbody runing into an enemy which also has a rigidbody

#

but the enemy gets confused bc it gets pushed by the bullet and it meses up the ai

#

how do i fix it?

spiral tulip
#

you can also make one of the colliders a collider and the other a trigger so that one still collides with other things, just not with the enemy

stuck bay
#

I have a problem... I have a gameobject that has a character controller (of course it has its own collider) .. and in one of its children i have added a collider too... I need the child's collider to be bigger than the parent's one ... here is the problem :: IN GAME MODE THE CHILD'S COLLIDER DOESN'T WORK it goes inside other colliders ... any help on how to solve this problem

stuck bay
#

where it stops is where the character controller collider hits (it is small and in the center of the object and the big collider is on the child game object)
and the rotation is done by a script put on the parent object

small sundial
#

i have two colliders on different objects: a small sphere collider on a projectile object and a player sized capsule on a player object. in the layer matrix, the projectile will not collide with the player. how can i get a bool (or an event) when the projectile is intersecting the player?

#

ping me if you have a solution

timid dove
timid dove
#

Re-enable collisions between those layers to get collision events between them

small sundial
#

and yes, i am developing your average fps

timid dove
#

you can detect the overlap without them physically affecting each other

small sundial
#

oh thanks

timid dove
#

Look up OnTriggerEnter

small sundial
#

so triggers have no collision?

timid dove
#

they have no physical collision

#

they just trigger your code

small sundial
#

ok

stuck bay
timid dove
#

like what are you expecting it to do

stuck bay
# timid dove like what are you expecting it to do

i am expecting that when the colliders hit other colliders of game objects to not interfere with them... look at the picture i uploaded above, half of the capsule collider (which is used on the child game object) is inside the wall which has a collider as well

stuck bay
timid dove
#

also if it's just a child object of the CC and there's no Rigidbody involved at all, that's just a static collider

stuck bay
#

by game object I mean the wall

timid dove
stuck bay
#

what do you mean by do your own custom capsule-casting solution

#

would a rigid body based character contoller let me use several colliders that will work simultaneously ?

timid dove
timid dove
#

you can put as many colliders on child objects as you want with a Rigidbody and they will all be considered part of the body

stuck bay
stuck bay
#

thank you

#

and just to make sure , if the parent and child capsule colliders dont collider and one of them isn't inside of the other , they still wont work?

timid dove
#

Are you talking about for the Rigidbody strategy or for a custom Capsule-casting approach?

stuck bay
#

i wanna make sure my current solution wont work at all

timid dove
#

Just using a CharacterController it will only respect the main capsule of the CC itself

#

no other colliders will be considered

stuck bay
#

thanks for making it clear

solar charm
#

howdy, just a quick question

#

how do i add force without intruding in the rotation?

#

i wanna move with addforce but i wanna keep the player rigidbody rotating in whatever direction it was rotating

inner cloud
#

in my fps i shoot a raycast from the player's view to interact with things, to avoid colliding with myself i use RaycastAll and bail when the hit is a child of my player, this works well but when i stand on the object to interact and try to interact with it looking straight down its the FLOOR that comes first in the raycastAll is this a bug ?

coarse veldt
#

The order of raycastall is undefined. You'd have to sort by hit.distance (or just search through for the closest)

stuck bay
#

Hello, is there anyway to update colliders positions, rotations and scale in the game if the Time.deltaTime is set to 0?

#

to be more specific I have an issue where I have an editor mode in my game that set the Time scale and delta time to 0, and I need to detect when my player is touching an object so I used physics.raycast to get an object at the position of the player touch but when I move this object the raycast doesn't seems to update the colliders positions and therefore it doesn't work properly

timid dove
timid dove
stuck bay
#

nevermind, I figured I could use Physics.Simulate() to update the colliders, it works now, thanks!

timid dove
#

If you call Simulate () then the rigidbodies will actually be simulated for one physics frame

#

Probably not what you want

stuck bay
#

yes that's not what I want ah ah, well I'll try this method

#

works great! thanks!

ripe estuary
#

so i'm learning colliders and rigibody in 2d. And i'm noticing if i take corners too tightly it'll mess up the orientation (i think) of the player object? Like it'll mess up which directional keys move which directions. Anyone know why this happens?

#

here's a small recording. You can see based on the animator which direction i'm suppose to move and that it works till i interact with the walls too much.

#

player character is the pacman in the middle

#

i'mma gonna go out on a limp here and assume it's cause I use transform.translate

ripe estuary
#

yep switching movement to velocity based worked

craggy grove
#

Hey - has anyone here ever projected a kind of "curve" based on where an object is going where they predict a possible upcoming collision?

I'm trying to find resources. Anything pointing along the way would be appreciated.

timid dove
#

(works best if it has no drag)

#

and use raycasts along that trajectory to check for collision

craggy grove
craggy grove
timid dove
#

I'm saying keep track of the position and velocity as you iteratively simulate each future physics frame in a for loop

#

For as many frames as you're willing to look ahead

craggy grove
#

Ahhhhhh okay. So increment in a for loop time.fixedDeltaTime by something like 1

#

Ah, nvm. time.fixedDeltaTime is THE frame physics interval set in the project. Okay, got it.

gleaming gorge
#

I'm having this weird bug,
my ragdoll always flies up whenever it gets activated, but only when the timeScale is less than 1, when the timeScale is 1 it acts normally (or at least it seems to act normally), what could be the problem here?

timid dove
#

are you perhaps doing physics things in Update?

gleaming gorge
arctic marsh
#

You got additional colliders that collide with ragdolls?

gleaming gorge
#

Just the floor, but it's outside below the ragdoll when it's activated

#

Wait, it seems that it flies up when ragdoll activated after certain animation

arctic marsh
craggy grove
#

Hey guys, I really appreciate the help that I've found here so far today. So I used @timid dove 's suggestion to calculate a projected position based on the velocity of my car object - and I THINK it's working. The deal is, now I want to turn the car an additional amount to what it is currently turning to follow the spline walker (yellow arrow). What I've been doing to get it to turn towards the spline walker is - take the InverseTransformPoint of the walker, and then divide the x value of that position by the magnitude to get the amount the car should steer (the value is a clamp between -1 and 1, with the first turning the wheels completely left and the latter turning them completely right). While that logic does work, I want to figured out the difference between the projected position, and the ideal position as indicated by the red marker here, and add that to the steering value. I would think that subtracting the ideal marker's position from the projected one's (light blue) would do the trick, using an InverseTransformVector function relative to the vehicle. However, I can't say this is working as expected. Plus, I ONLY want to do this if the angle is excessively wide. Would anyone be willing to give their two cents here on what I'm figuring out? Sorry if I'm overthinking things here.

gleaming gorge
#

Nope, I think the problem still remains

gleaming gorge
desert wave
#

try adding a force

#

that opposes the ragdoll's force

gleaming gorge
timid dove
#

Maybe it's some errant collision causing it

gleaming gorge
#

I ended up by setting Rigidbody.maxDepenetrationVelocity to 0. It seems that the rigidbodies inside the ragdoll are colliding with each other, and timeScale seems to magnify the 'separation' velocity.
I tried multiplying the maxDepenetrationVelocity by timescale but it still flies up..
Thanks for the help

timid dove
#

maybe that would be helpful?

gleaming gorge
#

Do you mean the Enable Collision flag? Yep, I've tried both checked and unchecked, and it still fly away.
Setting Rigidbody.maxDepenetrationVelocity to 0 works with a trade of that the collider 'might' sink a little into the ground, but I dont think it will be noticable (if it happens at all)

pliant basin
#

Anyone know why my rigidbody 2d cylinder likes to stick onto walls?

wide nebula
#

Because of friction

pliant basin
#

And how do i remove it?

wide nebula
#

You can make slippery materials by creating a Physics Material asset, changing the friction to 0, and applying that asset to the collider on your wall.

pliant basin
#

I cant put it into the box colliders materia

wide nebula
#

Sure you can

#

Make sure you're using 3D for 3D, and 2D for 2D.

pliant basin
#

Ok

bold seal
#

Can I get cloth to work with DOTS physics

twin storm
#

Hi everyone! I have an issue with colliders intersecting. I've checked everything including the contact offset. I am attaching a screenshot of what is happening. Thanks in advance.

#

The game is for the Ludum Dare game jam.

twin storm
#

@stuck bay Nope, their not triggers.

midnight glade
#

Anyone got any pointers for my 2 solutions for implementing whenever a "loot location" has been found? I'm currently using a circle 2d collider that extends outside the screen resolution as what I call my "View", which will scan the surroundings for loot. (it follows the player)

  1. Use a very simple gameobject with a collider and some LootData (position, loottype etc) on it so it is detected with collision by the view, and the prefab for the loot can be pooled to the location

  2. Let the Update() function look for the position of the LootData in a list of all the spawn locations and check if they're inside the view. However, since this will happen with each player, and going through all the LootData on the map I thought that I could divide the map into different chunks that the player searches for the positions in the current chunk instead.

Not sure which of these methods are the most efficient, since I am unsure of the performance different between using Physics2d to detect collision VS searching the positions in a list in a chunked area each frame
Any tips and tricks are appreciated

timid dove
#

Unity's physics engines use a quite efficient algorithm to divide the space of the world such that only a small area of it is being tested for collisions by your collider at a time.

#

in effect you are getting that "chunking" behavior for free

midnight glade
#

Ah sweet, I'll do that then, thanks!

tiny osprey
#

Is there any easy way to make meshes deformable through physics interactions? I want to something akin to making a cube of gelatin that deforms to a certain extent when something pushes into it

lapis plaza
#

not with stock physics

#

you need softbodies for that

#

well, one can still fake the effect at some extent but that's another topic

#

either way, not going to be easy

tiny osprey
#

Get the Obi Softbody package from Virtual Method and speed up your game development process. Find this & other Physics options on the Unity Asset Store.

Use the uFlex from Dr Korzen on your next project. Find this utility tool & more on the Unity Asset Store.

Use the VertExmotion tool from Kalagaan on your next project. Find this & more animation tools on the Unity Asset Store.

torpid prism
weary moon
#

does anyone know why a charactercontroller isnt actually moving?

#

im using the Move() function and when i do CharacterController.velocity it shows that it indeed does have a velocity

#

but its not actually moving

weary moon
#

EDIT: the reason was because the char controller was on a child object

obtuse marsh
#

Can someone help me make my formulas physics and stuff better in Unity?

#

DM me if yes

hollow echo
obtuse marsh
#

Idk anything more than that

earnest rampart
#

Hi guys i need help About vehicle physics in unity i am new in this server where i should ask?

obtuse marsh
#

Me too

#

When I get home from school I can show u, how I did it

earnest rampart
# obtuse marsh What your question is?

I want to learn how can i make vehicle controllers in unity i am struggling from weeks to get a good Tutorial or course that can teach but i cannot find anything even close to that i am looking for

#

I have some decent understanding of programming but i cannot code it myself because i have never worked on something like vehicle physics before

obtuse marsh
#

I can show u how I did it.... When I get out of school

earnest rampart
#

Peesonal*

carmine wedge
#

Hey! I'm trying to get the count of particles from a particle system within a specific collider... Any points on how to do this? ParticleSystem.ParticleCount only shows the total amount in a scene

carmine wedge
marble blade
#

Hello folks, having a issue with the simplest chain of ConfigurableJoints deforming in a strange manner. Any idea?

timid dove
marble blade
marble blade
#

And by solver iterations, I mean the physic engine iteration count in the project settings

haughty sparrow
#

Is this the right channel to ask about marching cubes?

weary moon
#

probably not lol

weary moon
#

does anyone have a solution for a character controller not being grounded when walking down a slope?

timid dove
weary moon
#

nope :\

#

i even tried to give it a downwards motion while its grounded

digital mesa
#

Any reason why a Physics.Raycast() will not a ProBuilder object if the object's transform has a rotation applied? I'm rotating the object around the Y axis, and raycasts aren't hitting it for some reason. (Specifically this seems only to be a problem when the object's Y-rotation is 90 . . . between 0 to 89 degrees the Raycast hits) . . . one more quick update . . . it seems to only happen at Y rotation values of "90" and "270"

digital mesa
#

. . . probably related to the Mesh collider on the object. I replaced it with a box collider and it works as expected now. So much still to learn.

timid dove
gleaming gorge
hollow topaz
#

Hello, I am having problems with addforce and hinges. When I apply a force (not torque) to a rigidbody object that also has a hinge it rotates child the hinge in a wacky way.

#

Currently I am applying a force to the knee and to the toes to get them to try and follow the IK (the green debug boxes). when I apply the force to the knee the limb below the knee moves more than it should.

#

This is with just the force added to the knee

lapis plaza
#

@tiny ospreyobi is probably best out of those options... also if you want flex, nvidia has free integration for it too but it's kinda abandoned

#

in addition bullet physics can also do softbodies

#

oh, nvidia took all their content out of asset store

#

well, their free flex integration is gone then

#

but yeah it was very limited for platform side