#⚛️┃physics

1 messages · Page 10 of 1

split dew
#

Thanks though :)

split dew
#

For anyone curious, I fixed the issue. I just had to make it so that the movement system is executed after the boyancy calculations in Fixedupdate

onyx olive
#

nice

#

also instead of doing moverotation you could add a rotational force

#

might make it feel better

split dew
#

ye definitely wanna do that. Want to add acceleration as well, and other stuff to make the whole movement system better in general cause right now its very wonky

lost lagoon
#

hey, perhaps I did not explain things properly so I'll try again.

  • I move objects using Transform.position and Transform.rotation.
  • I detect collision by using Physics.OverlapSphereNonAlloc everytime an object is moved
  • and then I perform corrections if collisions are detected.
    I've been informed recently, that altering the position of objects (which has a collider but no rigidbody) causes Unity to recalculate its physics scene (which can be performance intensive). I don't utilize forces or rigidbodies in my game but I do need colliders.
#

I'm trying to verify

  • If Unity even runs their physics simulation if no rigidbodies are actually being used.
  • Whether moving an object(with a collider but no rigidbody) would indeed impact said physics simulation
lost lagoon
#

Found some information which answers my questions.

stuck bay
#

Is it possible to calculate the initial y velocity for a rigidbody2d given different rising and falling gravity scales and a duration that I want the jump to be?

#

I keep getting 2 unknown variables in my calculations, the apex height of the jump and either the falling or rising time

timid dove
#

There are infinite combinations of rising and falling gravity scales that will get you the same overall jump duration

#

You will need to pin one of the gravity scales in the calculation to calculate what the other will be

#

E.g. 5up and 2 down might have the same overall duration as 2 up and 5 down.

#

And those might both have the same duration as 3 both ways

#

So total Jump duration is not enough information

#

You probably need to pin apex jump height as well

stuck bay
#

My ultimate goal was writing a function to jump to a specific position, so it ended up being

JumpTo(Vector3 targetPosition, float jumpTime, float jumpHeight);
fallow shadow
#

Hi,
Somebody know how to use the gradient tool for the cloth collider ?

topaz fox
#

HI guys, i have a problem with my tilemap collider. I have a player with edge collider, then terrain made with tilemap, with an tilemap collider, u can look those picture. The last picture show the bug, i'm litteraly into the tilemap collider. I success to be in the bug when i fly on the left or right side, not in front

timid dove
stuck bay
timid dove
#

currently you're using transform.position / Translate

#

that ignores the physics engine

stuck bay
#

Thank you that makes sense! This might be out of scope here, but is this a dangerous path to take for a top-down 2D JRPG? I'm looking for the simplest movement + simple collision handling for when the player moves into NPCs. Physics-based movement seems overkill, but I'm too new to Unity to know if this is actually the correct path.

timid dove
stuck bay
#

If I was to avoid physics movement, would an alternative be to set everything up as a Kinematic body and check for collisions (and handle them) myself?

timid dove
stuck bay
#

Thanks I will give it a go! Much appreciated.

stuck bay
high ether
#

Hey guys, I’m working on a off road project. I have the vehicle in game and drivable using NWH vehicle physics 2.

I have issues when it comes to animating my suspension. When I try and use the LookAt constraint on some of my parts to look at the target the mesh rotates either 90 degrees or 180 degrees or sometimes even in random directions.

I am using the unity FBX exporter so it imports fine it’s only when I use the LookAt constraint

Can anyone tell me what I’m doing wrong please? I’m sure I just need to orient the model in blender in a different way but I can’t figure it out

topaz fox
terse trout
#

I'm generating chunk meshes from voxel terrain data and I was using the mesh collider component for collision, but I want to add non-solid blocks. Is there a good way to do collision directly from voxel data and decouple collision from the mesh altogether? Thanks in advance.

unique cave
tough path
#

If I have 2 box colliders right next to each other without any spacing between them, and then my Rigidbody player runs right over the part where they connect, the player gets pushed up just slightly, as if they just hit a speedbump. Does anyone know why this is?

timid dove
tough path
#

How do devs get around this?

timid dove
#

reduce default contact offset, merge multiple colliders into one, move colliders around to make sure objects aren't going over seams

#

one or more of those^

terse trout
idle sluice
#

In need of some 2D help; I need a way to "attach" the player (with a Dynamic rigidbody) to a moving platform (also with a Dynamic rigidbody) so that the platform carries me as it slides along the ground. I know that parenting one of the objects works when the platform has a Kinematic rigidbody, which makes things much easier, but I need the platform to adhere to physics, so that's not an option.

timid dove
#

Or high friction material

idle sluice
#

what kind of joint?

timid dove
#

I'll say onr thing though it looks like your platform is simply not moving via physics currently

#

Make sure you move it either with velocity or MovePosition

#

You should get some friction based movement automatically then

#

Oh wait you are getting a small amount currently

idle sluice
#

I'm not sure what you mean

#

I'm not manually moving the platform at all

#

I'm pushing it

#

The platform has a zero-friction material on it; the decrease in speed is from the slope

timid dove
#

oh

#

well

idle sluice
#

I want to avoid high-friction materials since they create weird unwanted effects like awkward pacing and wall-sticking

timid dove
#

no friction means it's not going to move the player with it of course

#

anyway - a joint is a possibility as mentioned. I guess FixedJoint2D?

idle sluice
#

There's definitely some configuration of joints that will work properly

#

I just don't know which ones

#

FixedJoint doesn't really do what I want. It just sticks me on top and I stay there regardless of whether I want to move or jump.

timid dove
idle sluice
#

then i'll fly right off when I move

#

and I don't want that either

#

What I'm looking for is a joint (or alternative setup) with which the platform carries the player as if it were Kinematic.

#

In my head it doesn't sound that complicated.

stuck bay
#

Is there a way to retrieve a collider's mesh for visualization?

timid dove
#

most colliders don't use meshes

stuck bay
#

Then how does Physics debug view visualizes them?

timid dove
#

each collider is a special case

#

MeshCollider of course has a mesh

#

the others are drawn based on their characteristics

stuck bay
#

Okay so, I would need to create new mesh for each of them?

timid dove
#

What are you trying to do?

#

visualize where/how?

#

At runtime?

#

In the editor?

stuck bay
#

I need to draw gizmos for custom volumes in editor

stuck bay
#

Yeah I was hoping I could just get the mesh instead of finiding the collider type

timid dove
#

¯_(ツ)_/¯

stuck bay
#

But thanks for the help

timid dove
#

The colliders all have gizmos already so it's unclear what you need to do

stuck bay
#

I want the gizmos to be clicakble, so I can select them in scene view

#

The collider gizmos are only visible when they are selected

timid dove
stuck bay
#

One last question, is there a way to get the convex baked/cooked mesh from mesh collider?

simple hearth
#

I think that would work

#

for example

#

if the player is on ground and the ground is the platform, then add the platform's velocity to player

#

they technically could move synchronized

idle sluice
#

Thought of that. I only see it working for one frame, because then it's going to add the platform's velocity again, and again, and again until I just zoom right off the side.

simple hearth
#

I don't know how though

#

welp

#

maybe you can just manually push the velocity to player

#

and not update the player's velocity

#

like

#

you can teleport the player to position by the velocity of the platform

#

so it won't touch player velocity

#

but still could move it

#

for example put a field that adds the platform velocity to player position in case the player is on platform

#

if you just put it to player velocity, since the player velocity will stack up it'll cause problems naturally

dark moss
#

I would suggest maintaining a list of objects you are touching (Use the normal vector to see if it's something you're standing on or just a wall you ran into), and if they have a "moving platform" script or something then move the player (with rb.moveposition()) every frame the exact amount that the platform will move that frame. Probably avoid messing with velocity.

#

You could probably make it preserve momentum when you're jumping off a moving platform by adding the right amount of force in the OnCollisionExit callback

idle sluice
#

the exact amount that the platform will move that frame
How can I get this? multiplying velocity by delta time?

tender grove
#

im adding wheel colliders to my mesh but they just go straight through the floor

#

only my box collider on the body of the car hits the ground

#

so my wheels are half in the ground

simple hearth
#

You can do that in fixed update I think

heavy valve
#

anyone know why the cube is clipping through the larger sphere while the smaller one seems to be colliding perfectly fine with it

topaz fox
#

Hello, is that possible to have collider in this sprite, only on the red, i don't succed to do it

floral river
#

Possibly, but I just wouldn't do it. What are you trying to achieve?

native igloo
#

what I have here is that I have a rope with armatures that works like a wire, how do i make it so that the end tip of the wire is attached to the nozzle? since im very new to physics, I have no idea how to do this, thank you

topaz fox
native igloo
native igloo
floral river
topaz fox
#

I'm pretty new, that the first Idea i had
But i will try this

stuck bay
#

is there a way to define boxcasts by start and end point instead of direction+maxdistance etc ?

#

kind of like a linecast or something

#

(just for convenience sake)

timid dove
placid nimbus
#

Both the wall and Bonzi Buddy have colliders (bonzi has a cube attached to him, as you can see,) but yet he still phases through walls? pls help

twin nebula
#

Can anyone tell me why the hell this happens?

#

Please ignore how... weird.. the worm looks

#

I'm not the best modeller

#

All bones are connected via config joints

#

Colliders overlap I don't know if that's why

#

If I move back and fourth the joints are REALLY weak

#

Like they compress into eachother

half creek
#

Hello, I noticed that Physics2D.RacastAll does't hit colliders that have offset the collider component. So for exaple a BoxCollider2D with offset (0, 0) is being detected by RaycastAll just fine, but the same collider with offset (-6.1875, 0.34375) is not detected. Is it a bug or should it be like that? Maybe it should be reported to Unity staff? I digged in documentation and didn't found a word about such behaviour

stuck bay
timid dove
timid dove
half creek
#

yeah, it might be a mistake on my side since a couple of rays also didn't detect colliders with no offset. I have no idea what might be the couse - at this point results seem random

timid dove
#

you may also have improperly set up a layer mask or contact filter or something of that nature

stuck bay
rare juniper
#

I’m building an fps game and have a character controller for my player currently. I want the player to be able to get in and out of aircraft. Should I use a rigidbody for the aircraft so that I can apply drag? Or should I make the aircraft a character controller as well? What do most people do typically when combining vehicles and players?

timid dove
rare juniper
#

I know I can add drag affects to the aircraft similar to how I can add that to a player character controller. But idk if an aircraft needs to be as snappy, so I’m thinking maybe a rigidbody would make more sense? Idk

timid dove
half sky
#

Hey guys!

My game started getting lag spikes even though its still barely has any scripts. I went on the profiler and I see this:

On the spike, theres like 8 physics.processing and I dont know from where they are coming from. I dont use Physics.Simulate and the only physics I use are raycasts & rigidbodies for the player. I dont understand why this is happening and I need some help please

timid dove
#

it's running 8 times that frame presumably because the previous frame took a long time to process

half sky
#

So my game getting a huge lag spike every 40 seconds is normal?

timid dove
#

no

#

but the physics engine running multiple phsyics simulation steps when your framerate spikes is normal

half sky
#

so you are saying that because my game spiked the physics engine had to run more

timid dove
#

check the frame before that one

half sky
#

so its not directly the reason

#

I desperately need help with this im new so I was confused

timid dove
half sky
#

This is the frame right before

timid dove
# half sky

yeah just looks like the editor doing editor stuff

#

(161ms of EditorLoop)

#

This is annoying, but it won't be present in your build

#

so I wouldn't worry too much about it

half sky
#

WAIT REALLY?

timid dove
#

really

half sky
#

bro ive been shitting myself for the past few days 😭

half sky
#

is that 1ms after the current frame?

#

thank you tho legit was stressing so much over this

timid dove
half sky
#

so at this current frame I can see whats processing but why is there stuff on the left and right:

timid dove
#

the right arrow is the current frame you're looking at

#

the thing along the top is a timeline

half sky
#

so this editor loop is taking more time than usual

timid dove
#

yes

half sky
#

so this is normal with lag spikes when playing from editor since its both on same thread?

timid dove
#

yeah pretty much

half sky
#

ahhhhhh okay good to know, thank you so much again 🙂

stuck bay
#

Kind of confused about RaycastHit.point. If you're doing a 2d boxcast, and the edge of the box is parallel to the edge of the collider, aren't there infinite points along that edge of contact? Does it just take whichever point it happens to draw first?

timid dove
#

it might take an average, or pick an arbitrary point

#

it's not clear

stuck bay
#

on the case !

timid dove
rare juniper
#

Anyone successful in using Jobs/burst to render thousands of bullets/projectiles? How would I go about detecting hits doing this? It seems like most solutions I have found rely on gpu instancing and DrawMeshInstancedIndirect; however, these are no longer gameobjects, so I'm not sure how to do hit registration on other players

rare juniper
#

Thanks @timid dove! I was thinking the job system with gameobjects might still be too much overhead if I have say 64v64 players in a close area all shooting

#

I might give it a shot though

onyx elm
#

hello so my player has a character controller and i wanted to make the player push a box so i parented the box to the player so that it follows the player but when doing so now the box goes through other colliders any idea how to fix that

timid dove
onyx elm
#

i could also do a boxcheck to check for collisions and push the box away from the wall its colliding with

timid dove
#

It kinda depends on your requirements for how "pushing" works

onyx elm
#

not sure but just parenting the box so it follows the player was easy until i saw that it didn't collide with other colliders

timid dove
#

you're not sure how you want it to work?

#

then it's not really possible to give you a solution

onyx elm
stuck bay
stuck bay
onyx elm
timid dove
stuck bay
stuck bay
onyx elm
#

lemme check again

stuck bay
#

Do you need the box to be the child of the player

onyx elm
stuck bay
#

of doing what

#

pushing the box ?

onyx elm
#

yeah so it follows the player correctly

#

if there's a better way i'd love to experiment

stuck bay
#

If you're using a rigidbody then the collider will push the box, so it wouldn't need to use the player as a parent to move anymore

onyx elm
#

i wanted more control over the box cause its supposed to be for puzzle solving

#

it has to be precise

stuck bay
#

If you want exact 1:1 movement with the player, then you could set Rigidbody.velocity = (whatever your character controller is using to represent velocity) every fixedupdate

onyx elm
#

so push, pull, side movement

onyx elm
#

good idea too

stuck bay
#

just thought about it and there will probably be desync if your character controller is not using fixedupdate (which it prob should be)

onyx elm
#

hmmmm

#

yeah the player is using a character controller

#

wait what i tried again and its not going through a wal lol

#

but the movement is messed up the rigid body is acting weird gonna have to dig more thx for your help buddy i'll consider everything you said

#

i figured it out so locking the Y position fixed the weird movement now the box follows the player correctly and collides with other colliders

river bronze
#

Hey guys I'm fairly new to unity and I'm trying to set up a 3d platform where everything has a locked z position and locked x and y rotation. I tried creating a ragdoll with configurable joints which seems to work when it's not locked in any way but as soon as I lock the z position and x and y rotation on all the body parts it freaks out. Is there a better way to do this?

gilded latch
#

Hello, everyone. I just don't know what to do anymore. When I use addForce to make my character jump, he just fly away from the screen. It doesn't matter how much force I apply. Can anybody give my some direction?

timid dove
#

If you're doing it continuously it's like a jetpack

#

You need to just think about what your code is doing. It's not magic nor a mystery. It does what you say

gilded latch
#

Right. I'll try

midnight dagger
#

Hi guys, I'm having a problem with player collision with tilemaps. I have 5 layers inside the Grid, the first layer is in Order in Layer 0 and so on. The player is in layer 1. In the layers that I want to have collision with the player I have the components shown in the image. Can anyone help me understand why this is not working?

timid dove
#

Collisions are based on the layer of the GameObject and whatever you set up in the physics 2d settings for the layer collision matrix

#

You would also have to show the components on the player and explain or show how the players movement code works

#

The short of it though is make sure your player is actually moving in a physics aware way

midnight dagger
timid dove
#

That's not the movement

#

Ah I see the code now

midnight dagger
timid dove
#

You're using MovePosition which doesn't respect collision

#

You have to use velocity or adding forces to get collision

midnight dagger
#

can this solve it?

timid dove
#

Yes

#

Assuming you delete the other code

#

Unclear to me why the if is required though

midnight dagger
#

do you think it may be another problem?

timid dove
#

As well as the gizmos for the colliders on both objects

#

Does the player actually even have a. Collider?

midnight dagger
midnight dagger
midnight dagger
timid dove
#

The code is ok

timid dove
midnight dagger
#

Oh forget it, I'm confused hahahah

#

The objects layers is default for all

#

and don't have tags neither

timid dove
#

Tags are not relevant

#

Have you changed any settings in physics2d settings

midnight dagger
#

here? No

fringe olive
#

Question:
As far as i know, Unity events and physics are NOT multithreaded.
Which means, that no OnTriggerEnter calls can ever happen in parallel, right?
Also, there is no way an Update-Call happens while OnTrigger-calls are happening, right?

Tell me if i am wrong.

midnight dagger
#

So I'm necessarily need the OnTriggerEnter?

timid dove
midnight dagger
timid dove
midnight dagger
timid dove
#

to show gizmos yes

midnight dagger
timid dove
#

you dont need to expand it

#

just toggle it on

midnight dagger
timid dove
#

ok s

#

so show me the gizmos

midnight dagger
#

is that white line you talk about?

#

I'm really don't know, sorry 😅

fringe olive
midnight dagger
timid dove
midnight dagger
timid dove
#

those tiles look like you probably need to create custom physics shapes for them

#

since they're totally opaque

midnight dagger
timid dove
#

probably putting one giant rectangle on the very edge of the map

#

because you haven't defined physics shapes for your tiles

midnight dagger
midnight dagger
#

wait but I do that in the intire tilemap right?

#

thank you very much for the time invested in helping me @timid dove blushie but I think I'll follow another YouTube tutorial, I have been stuck for about 3 days with this problem and want to learn the right way

cinder umbra
#

hey, having a strange isssue with an animator where if it's not constantly doing anything, the avatar will sink into the floor. I am attempting IK for the avatar's legs and the feet meet the floor fine, but the legs go beneath the floor, with their target points below as well. I have no idea what's causing this, I just added a change that makes the walking animation the IK is based on only activate when the character is under motion, but I have no idea why it would cause this.https://i.imgur.com/2KRN2tk.png

#

{ animator = GetComponent<Animator>(); newPos = GetComponent<Transform>(); animator.SetTrigger("Moving"); animator.ResetTrigger("Moving"); } private void Update() { if (animator!= null) { if (newPos != oldPos) { animator.SetTrigger("Moving"); } else { animator.ResetTrigger("Moving"); } oldPos = newPos; } }

#

this is the new code that seems to have caused the issue

cinder umbra
#

let me know if you know what's going on or how to help. Didnt know which channel to post this in since it seems like a combination of things. Thanks!

cinder umbra
dim fulcrum
#

Can I have a "isTrigger=true" collider used for picking the object up, and colliders & rigid body on the same object, or should I nest them somehow to avoid having multiple on the same object?

dim fulcrum
#

I'm attemting to throw an object from a third person character like this:

        var rb = item.GetComponent<Rigidbody>();
        rb.isKinematic = false;
        rb.velocity = Vector3.zero;
        rb.angularVelocity = Vector3.zero;
        rb.AddForce(direction * maxForce, ForceMode.Impulse);```
But the thrown object still picks up momentum from the throwing character, I'd like there to be no difference if the character is idling or running or jumping what else can I zero on the rigidbody?
timid dove
dim fulcrum
#

I'm doing all of this releasing in Update() I'm now thonking this has something to do with it?

dim fulcrum
#

I tried with a courutine waiting for fixedupdate first but it made no difference. I think, setting parent to null, THEN waiting for nextfixedupdate does the trick but I've been starring for this for so long I'm going to need to fix a couple other issues to be confident that's what I wanted

dim fulcrum
#

One more: Add a Player and Items layers. Assign my player character and an item to the layers, and disabled their collisions in the collision matrix. Still my character get's stuck on the items rigidbody?

timid dove
dim fulcrum
#

@timid dove turned out I miss assigned something, separating the player and items worked. (Actually ended up swallowing them to a projectile layer as they re are thrown, and assigning back to items layer on collision)

dusky sapphire
#

How would I go about creating collisions for the rim? I tried mesh collider but it did not work out

timid dove
dusky sapphire
#

But I need it if I want a rb to collide with it

timid dove
#

No

#

It only needs to be convex if has its own dynamic Rigidbody

#

Which this won't since it doesn't need to move

#

Do you know what convex means? Google it

dusky sapphire
#

Ok

#

thanks

topaz fox
#

Having a lot of collider Can mess UP with performance ?

unique cave
gray sentinel
#

Not sure if this is the right spot for this question.. but here goes. I have a gameobject with a sprite and rigidbody, with some additional child objects with sprites (no rigidbody). I have the rigidbody set to interpolate and it moves ok but all the attached sprites do not, they tend to jitter a bit. I'm not entirely sure what the fix is for this, do I need to put rigidbody's on all child sprites too? That seems like an inefficient solution.

timid dove
#

Sprite is an asset btw, not a component. Maybe you mean SpriteRenderer?

#

putting Rigidbodies on the children would make them separate physics objects, which I doubt you want.

gray sentinel
#

@timid dove Yes SpriteRenderer is what I meant. Maybe jitter is the wrong term, it seems to be updating it's position correctly, it's just the per pixel movement is very noticable. I think the child objects would need to blend a bit between pixels. I have no idea what that is called or if it's even a thing.

timid dove
gray sentinel
#

I am using that one

gray sentinel
#

I'ts only really noticable when the rigidbody is moving at slow speeds, as the attached gameobjects hop over to the next pixel.

wheat pike
#

Hello guys can I ask here some help about some issues of clothing simulation?

dim fulcrum
#

I have a throwable item with a box collider and a rigidbody I can throw around, I'd like to make it so if it hits with a specific part it'll stick to other objects (it's an axe). I thought I can add another boxcollider (possibly trigger?) and in oncollisionenter I could manually check if the item I collided with also collides with my "blade" collider, but...
seems I can't have 2 boxcolliders? (actually if the blade is trigger I can?) and there's no way to "manually" determine a collition as far as I can see in the docs?

dim fulcrum
#

(I tried putting a trigger on a child object, but it seems regardless of the configuration, the parent collider always hits before the child's ontriggerenter)

dim fulcrum
#

(I made some silly mistake, and the child object approach works, also found a thread somewhere saying that by design unity doesn't expose the collision api from the underlying physics engine, so it's not possible to use the colliders directly to determine if they're overlapping / colliding)

twin nebula
#

..Why?

#

The limits are doing nothing

#

Y and Z are locked X is limited

stuck bay
#

Hello, I am making a 2d infinite runner.
I am having an issue with the physics of the objects that move from the right to the left side of the screen.
The problem is that the objects movement feels jittery/laggy and I dont know how to fix this.
(I already tried turning on Interpolate, but it only makes things worse)
All the game objects have this script:

using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{
    [SerializeField] private float MovementSpeed = 5;
    private Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    private void Update()
    {
        
    }

    void FixedUpdate()
    {
        rb.velocity = new Vector2(-MovementSpeed, rb.velocity.y);
    }
}```
#

Every game object has this settings in its rigid body:

#

I thought that this might be a camera issue so here are it's settings:

timid dove
stuck bay
#

Oh right, I wrote this message so many times that I just forgot

#

I just edited the first message

timid dove
#

Does your camera move?

stuck bay
#

Nope, it's always on the same coordinate

#

All the other objects move, but not the camera

timid dove
#

Can you show a video of the problem? Are there any other scripts involved? From the description so far it sounds quite basic and there should be no jittering

stuck bay
#

I can't show a video right now, I am gonna send it later

stuck bay
#

Here is the video:

stuck bay
#

It might be a bit hard to see the lag, but it's pretty annoying when the game becomes faster

timid dove
# stuck bay

Honestly not seeing it at all. Maybe it's a pixel perfect camera thing? Which object am I meant to be looking at?

stuck bay
kind sky
#

how can i fix this bouncy problem on the cube

#

i have it freeze on land then the player just bounces off

tough pelican
#

Hi, I'm trying to implement health and ammo pickups in 3D. Each pickup contains a rigidbody and collider with IsTrigger set to true. I have a script with an OnTriggerEnter method that checks if the pickup collides with the player. It works well, except pickups pass through the floor when I have gravity on. Is it possible to have it where pickups will pass through the player, but not pass through anything else?

stuck bay
#

I noticed that when the game starts to lag, in the statistics I can see that "saved by batching" increases, but I don't know if the lag is cause by this because I don't even know what does this mean

timid dove
#

use the profiler

#

it's probably just the editor though

stuck bay
#

What the heck is the profiler...
Gonna check on google

#

Uhhhhhh I'm not really understanding much

stuck bay
# timid dove use the profiler

Oh okay I am starting to understand.
I noticed that after a bit of time the rendering part starts to do some weird stuff

tranquil shadow
#

how performance-heavy is it to have alot of active physics joints?

#

im talking hundreds at once

unique cave
tranquil shadow
#

also, how can i make fixedJoints not bend and actually be y'know, Fixed?

vague fjord
#

Hello! I'm in need of some little help! I'm trying to align a rigidbody to the ground normal. I have tried tons of things and my current code is something like this:

rigidbody.MoveRotation(Quaternion.FromToRotation(transform.up, normal) * rigidbody.rotation);

This works kinda nice, BUT, when the rigidoby changes to a new plane or hits a collision, the rotation does not go back to normal, instead it gives me a little deviation:

In the image below, you can see what I'm talking about. I'm standing on a plane with normal 0,1,0 and after a collision it's not getting aligned (Rotation should be 0, x, 0). I don't know what to do more or what is even the cause of the problem!

arctic hearth
#

Hey, @verbal monolith , how'd you make that interaction system? I made one but my physics objects don't have collision when held.

verbal monolith
#

I dont understand half of this myself lol.
If you want, I can send you the code in dms

arctic hearth
#

Eh, I'm strictly VS only for now, I was just hoping I would be able to translate it into VS from C# lol

arctic hearth
#

Yeah

verbal monolith
#

oh ok

arctic hearth
#

Basically C# but visual

verbal monolith
#

yea

#

I never used VS, so I dont know how to translate the code in to it

arctic hearth
#

I do, I'm just not familliar with what a PID controller is

verbal monolith
# arctic hearth I do, I'm just not familliar with what a PID controller is

Ok, I honestly had WAY more fun making this tutorial than I should have. This kind of movement is so addicting. In this video I use a basic PID controller and Hooke's Law to add Gorilla Tag's physics based movement to our Unity VR project. Run, climb, and launch your way around in this new Unity XR tutorial! We're using Unity 2021.2.7f1 and the ...

▶ Play video
#

this is the best explaination i could find lol

#

i also partially use the code from this tutorial

arctic hearth
deft orbit
#

i'm trying to apply a torque to get an object to a specific rotation as fast as possible
https://discussions.unity.com/t/determining-the-torque-needed-to-rotate-an-object-to-a-given-rotation/15484/2
the closest thing I've found is this, but it doesn't actually stop the object from rotating

#
targetDirection = Vector3.Slerp(currentDirection, targetDirection, 0.5f);
var x = Vector3.Cross(currentDirection.normalized, targetDirection.normalized);
float theta = Mathf.Asin(x.magnitude);
var wd = x.normalized * theta / Time.fixedDeltaTime; // desired ang. vel  
var wr = rigidbody.angularVelocity; // current ang. vel
var q = transform.rotation * rigidbody.inertiaTensorRotation;
var t = q * Vector3.Scale(rigidbody.inertiaTensor, Quaternion.Inverse(q) * (wd - wr));
return t;```
this is my current version, it still oscillates a lot
timid dove
#

like - with some maximum amount of torque? Or literally in one frame if you can manage it?

deft orbit
timid dove
deft orbit
#

This is for a relatively detailed simulation, so simply changing the rotation is unfortunately a no-go.

timid dove
#

you're going to need at least two torques then

#

one to speed up to a rotation towards the desired orientation

#

another to slow down back to zero

#

this is essentially a PID controller for desired orientation

deft orbit
#

the code above can reach wd in optimal time without any problems, so yeah, it's probably me not understanding maths

#

I've tried clamping wd to the sqrt of 2 * a * s in accordance with the braking formula (https://en.wikipedia.org/wiki/Braking_distance , mu * g = a, d = s)
it significantly reduces the braking speed, but doesn't completely cancel out the oscillations

#

Is there maybe something wrong with my code? I'm not used to working with angular velocity and torque, so I doubt this is 100% correct

Vector3 a = Quaternion.Inverse(q) * Vector3.Scale(Inv(rigidbody.inertiaTensor), q * maxTorque);
float maxw = Mathf.Sqrt(2 * a.magnitude * Vector3.Angle(currentDirection, targetDirection) * Mathf.Deg2Rad);```
#

(wd is clamped to maxw)

ripe hull
#

hi, i would like a little help please!

in my 2d platformer, i've noticed that whenever the character is just moving sideways, not jumping or falling, their Y veocity somehow reaches a really, REALLY low number. would anyone have any explanation and/or way to stop it?

#

nevermind, i just realised that's a really small number :/

jagged nacelle
#

I have an object which needs to move continuously in a given direction. However, it seems to stutter sometimes. Does anyone know why this could be?
Currently I'm making it move by setting its rigidbody velocity during every Update frame. Is this a poor implementation?

Rigidbody component attached
Movement code:
private void Update() { rigidbody.velocity = speed * Time.deltaTime * transform.forward; }

jagged nacelle
sharp ruin
#

Hi 🙋🏻‍♂️
Newbie simple question: ¿How can I "reset" the velocity (to zero) of a game object?
In a 2D game where I have a simple ball, when the game starts it fall because the gravity, but I have a script that when my gameobject reach y=-500 it move it to the position y=0.
That works! but it continue moving from that point (y=0) but it travel near to speed of light 😅
How can I reset that "property" so when I move it to y=0 it start to fall down slowly (like when the game start)?
Thanks in advance 🙏🏻

stuck bay
#

I'm having collision problems with an engine.

Does continuous collision work even when you manually change the transforms?

wide nebula
timid dove
#

Even in FixedUpdate

fringe olive
#

Hey, which **types of layer **do you create and why?
I got

  • Player
  • Actors
  • Projectiles
  • Weapons ( camerastacking on top render )
  • Level-Static
  • Level-Dynamic
    Have you ever subdivided a category you had for technical purposes?
    Hve you ever regrettet splitting objects into categories?
timid dove
#

Use layers as needed for specific interactions

north summit
#

Hi, I need help with configurable joints, I saw a tutorial about joints and it's working, but when I duplicate the object with the same properties the configurable joint just breaks, it just falls to the ground or teleports somewhere else in the map.

north summit
#

Ping when reply.

patent isle
#

is it better to have continuous or discrete collision detection on the player character
in a 2D game

floral hazel
#

Continuous is more accurate but takes more processing power.
But yeah so long as you don't put it on everything it can be really useful.

#

Not that the processing cost of the collider is gonna be relevant in most indie games. Except maybe on really weak mobile devices in some exteme scenario...

timid dove
#

if there was a "better" one, the other setting wouldn't exist.

dense sky
#

I installed Unity (v2022.3.4f1) on a new PC and I'm having an issue that I've never encountered before with the Custom Physics Shape editor. I'm not able to select or create points. Whenever I try to drag a point to move it or select somewhere on an edge of the shape to create a new one nothing happens.

dim fulcrum
#

I'm trying to transition an animated model to a ragdoll in unity and it looks "explosive". I already set each rigidbody's velocity and angular velocity t; zero. what else can I try?

timid dove
dim fulcrum
#

Wild idea: call physics simulate manually after the anim ends then zero the forces ? but I'll try making the ragdoll colliders smaller first..

hexed violet
#

Hi there people, I would like to ask for your opinion on a situation I have, so let me explain. I am moving a hovership over a track using Unity Physics engine. I have 2 functins that calculate the torque for the hovership this way:

// Do some inputs and other stuff
private void FixedUpdate() {
  Vector3 torque = CalcSteeringTorque();
  // Do some methods to check if there is track bellow the ship
  if (trackDetected) {
    torque += CalcStabilityTorque();
  }
  rb.AddTorque(torque, ForceMode.Acceleration);
}
#

Now

#

This is the CalcSteeringTorque() method:

private Vector3 CalcSteeringTorque()
{
    currentSteer = Mathf.MoveTowards(currentSteer, targetSteer, steeringSettings.acceleration * steeringSettings.accelerationMultiplier);
    steerRollAngle = -currentSteer;
    Vector3 torque = transform.up * currentSteer;
    return torque;
}```
#

And this is the CalcStabilityTorque() method which uses a PID to apply the right torque to align the Y axis of the ship with the Normal vector of the face bellow it:

private Vector3 CalcStabilityTorque()
{
    Vector3 headingError = Vector3.Cross(Vector3.up, transform.InverseTransformDirection(hit.normal));
    Vector3 headingCorrection = stabilityPID.Update(headingError, Time.fixedDeltaTime);
    Vector3 torque = headingCorrection * stabilitySettings.torqueMultiplier;
    return torque;
}```
#

And this is the FixedUpdate method:

private void FixedUpdate() {
    Vector3 torque = CalcSteeringTorque();

    trackDetected = Physics.SphereCast(raycastOrigin.position, hoverSettings.sphereRadius, -transform.up, out hit, hoverSettings.rayDistance, layerMask);

    raycastOrigin.localPosition = raycastOriginStartPos + transform.InverseTransformDirection(rb.velocity.normalized) * rb.velocity.magnitude * 0.025f;

    if (hit.transform != null && hit.transform.tag == "Track")
    {
        torque += transform.TransformDirection(CalcStabilityTorque());
    }

    rb.AddTorque(torque, ForceMode.Acceleration);
}```
#

And this works just fine, it gets the job done but....

#

As you can see in this line of the CalcStabilityTorque() method:

Vector3 headingError = Vector3.Cross(Vector3.up, transform.InverseTransformDirection(hit.normal));```
It can be changed to to simplify it like this:
```haskell
Vector3 headingError = Vector3.Cross(transform.up, hit.normal);```
hexed violet
#

Which avoids some estra steps in the calculation process

#

The issue with removing all that extra calculations is that after running over the track for a while, it makes the ship to slowly and constantly turn into one direction

#

Any idea why can this be happening?

twin nebula
#

How would one make a detached rigidbody affect another rigidbody?

#

In this case I want to have a rigidbody following an XR controller and I want to make it so the rigidbody can affect the main body rigidbody

#

Like for example you slam your hand into a wall you get pushed back or when you hang on a ledge

high imp
#

hi, i probably posted this question in the wrong channel. i'm having a RigidBody2D problem when trying to collide with a CompositeCollider2D. any chance someone can help me? here are the details: #💻┃code-beginner message

#

i think it's something simple, but i really can't tell. none of the OnCollision events are being called on the Player GameObject

#

wait... do i need OnCollisionEnter to be on the same object that has the RigidBody2D? Facepalm

#

that's exactly what it was Facepalm disregard

tacit laurel
#

how is havok compared to unity's physx?

stuck bay
tacit laurel
stuck bay
#

im not sure

tacit laurel
#

ok just read about it. it's ECS only and pro or enterprise license

stuck bay
#

Oh that’s sad

tacit laurel
#

it's meant to replace unity's broken attempt at physics 😆

spare cove
#

hiii are there any algorithms that can suggest the optimal shot in a snnoker game ?

tidal pelican
#

Hi guys, hope someone here is expert of Inverse Kinematics

I have a robotic arm, I set the Two Bone IK and works fine if I don't move the target on z axis.

The main issue when I start to move the target on z axis it's that my Two Bone IK rotate obviously on its axis but my base that rotate thanks to Aim Constraint have different position. I tried to put my arms child of base, so the arm rotate refers to the center point of base, but in this way my arm take the rotation of the parente (the base) and also the rotation of Two Bone IK.

Video attached

timid dove
late path
#

not sure if this the correct place to ask, but how do i make my rigid body only be able to go around a specific range on the x axis? For example: only allow the rigid body to go from x=-5 to x=5

devout token
late path
devout token
late path
devout token
hexed violet
#

Hello there, I am moving an object by applying forward force (800) to move it forward and I also apply force to move it sideways (20), the problem is that the faster the object is traveling forward, the less effective the force applied sideways is

#

when the object is still, the object can be moved sideways, but as it approaches the max speed, it is almost impossible to move it sideways

#

Any way to fix this?

timid dove
# hexed violet Hello there, I am moving an object by applying forward force (800) to move it fo...

the faster the object is traveling forward, the less effective the force applied sideways is
not really true... you probably just notice it less because it's a smaller proportion of the velocity

I am moving an object by applying forward force (800) to move it forward
This is a huge force amount. You are probably doing something kinda fishy here - like using the incorrect ForceMode or something along those lines

hexed violet
#

Probably I am doing something wrong

#

let me show you

hexed violet
#

this is the FixedUpdate():

private void FixedUpdate()
{
    Speed = Mathf.Sqrt(rb.velocity.x * rb.velocity.x + rb.velocity.y * rb.velocity.y + rb.velocity.z * rb.velocity.z);

    Vector3 force = CalculateThrustForce() + CalculateStrafeForce();
    Vector3 torque = CalculateSteeringTorque();

    if (DetectTrack())
    {
        hovercraftAnchor.position = hit.point;
        torque += transform.TransformDirection(CalculateAligmentTorque());
    }
    else
    {
        hovercraftAnchor.position = raycastOrigin.position - (transform.up * 10f);
    }

    hovercraftAnchor.rotation = Quaternion.Lerp(hovercraftAnchor.rotation, raycastOrigin.rotation, Time.fixedDeltaTime * 100f);

    rb.AddForce(force, ForceMode.Acceleration);
    rb.AddTorque(torque, ForceMode.Acceleration);

    CalculateStabilityInfluence();
        
    transform.position = Vector3.Lerp(transform.position, hovercraftPivot.position, Time.fixedDeltaTime * 80f);
}```
#

And these are all the other methods:

private float currentThrust;
private Vector3 CalculateThrustForce()
{
    currentThrust = Mathf.MoveTowards(currentThrust, targetThrust, thrustSettings.acceleration * thrustSettings.accelerationMultiplier);
    Vector3 force = transform.forward * currentThrust;
    return force;
}

private float currentSteer;
private Vector3 CalculateSteeringTorque()
{
    currentSteer = Mathf.MoveTowards(currentSteer, targetSteer, steeringSettings.acceleration * steeringSettings.accelerationMultiplier);
    Vector3 torque = transform.up * currentSteer;
    return torque;
}

private float currentStrafe;
private Vector3 CalculateStrafeForce()
{
    currentStrafe = Mathf.MoveTowards(currentStrafe, targeStrafe, strafeSettings.acceleration * strafeSettings.accelerationMultiplier);
    Vector3 force = transform.right * currentStrafe * strafeSettings.forceMultiplier;
    return force;
}

private Vector3 CalculateAligmentTorque()
{
    Vector3 headingError = Vector3.Cross(Vector3.up, transform.InverseTransformDirection(hit.normal));
    Vector3 headingCorrection = stabilityPID.Update(headingError, Time.fixedDeltaTime * 8f);
    Vector3 torque = headingCorrection * stabilitySettings.influenceMultiplier;
    return torque;
}

private void CalculateStabilityInfluence()
{
    if (rb.velocity.magnitude > 100f)
    {
        float influence = MathUtils.Remap(rb.velocity.magnitude, 0f, 1000f, 0f, 200f) * stabilitySettings.influenceMultiplier;
        Vector3 velocity = transform.forward * rb.velocity.magnitude;
        rb.velocity = Vector3.Lerp(rb.velocity, velocity, Time.fixedDeltaTime * influence * 10f);
    }
}

private bool DetectTrack ()
{
    trackDetected = Physics.SphereCast(raycastOrigin.position, hoverSettings.sphereRadius, -transform.up, out hit, hoverSettings.rayDistance, layerMask);
    float offset = Mathf.Clamp(rb.velocity.magnitude * 0.015f, 0f, 5f);
    raycastOrigin.localPosition = raycastOriginStartPos + transform.InverseTransformDirection(rb.velocity.normalized) * offset;
    return hit.transform != null && hit.transform.tag == "Track";
}```
#

To help you understand:

  1. Calculate thrust and strafe force based on inputs
  2. Detect track (cast a ray under the hovercraft)
  3. If track is detected, align hovercraft up vector to the normal of the face hit by the ray by applying torque
  4. If track detected move hovercraft anchor to the hit point, if no, then move it to start casting point -10 (so it always stays below the ship)
    • The hovercraft anchor has a pivot point hat the anchor's position + 10 over it's local z (just where the hovercraft should be)
  5. Rotate the hovercraft to fit the pivot point rotation
  6. Apply forces to move the hovercraft
  7. Apply torque to rotate the hovercraft
  8. Move the hovercraft to the pivot point
#

Let me shot you a video

#

As you can see in the video, strafe force is not enough to push the ship sideways the faster it goes

#

The ship roll is just an animation of the mesh, it does not affect movement

timid dove
# hexed violet this is the FixedUpdate(): ```haskell private void FixedUpdate() { Speed = M...

uhhh
Speed = Mathf.Sqrt(rb.velocity.x * rb.velocity.x + rb.velocity.y * rb.velocity.y + rb.velocity.z * rb.velocity.z);
can just be
Speed = rb.velocity.magnitude; 😉
You don't need to do the pythagorean theorem yourself.

What's transform.position = Vector3.Lerp(transform.position, hovercraftPivot.position, Time.fixedDeltaTime * 80f); about? What object is this moving?

Also CalculateStabilityInfluence() seems to be doing some damping stuff that could easily wipe out the horizontal velocity

hexed violet
#

how do you quote in discord?

timid dove
#

>

hexed violet
#

Speed = rb.velocity.magnitude; - Thanks

timid dove
#

> type stuff here after a space

#

like this

hexed violet
#

got it

#

Let me show you what I mean with:

transform.position = Vector3.Lerp(transform.position, hovercraftPivot.position, Time.fixedDeltaTime * 80f);

#
  1. Green balls and line are the rays casted to find the track
  2. Cyan line is hovercraft's velocity direction
  3. Purple line is hovercraft forward direction
  4. Red ball is the anchor that is placed on the point where the green ray hits the track
  5. Blue ball is the hovercraft pivot that is directly above the hovercraft anchor

I used to use a mechanic that implies using a PID controller to apply up and down force to keep the ship hovering over the track, but it didn't work for high speeds, the ship used to lose the track constantly or crashed into it, so I came out with the anchor-pivot idea

An anchor is placed where ever the ray hits the surface on the track and the pivot distance from the anchor defines the distance I want the hovercraft to be away from th track

#

So that's why I do:

hovercraftAnchor.rotation = Quaternion.Lerp(hovercraftAnchor.rotation, raycastOrigin.rotation, Time.fixedDeltaTime * 100f);
transform.position = Vector3.Lerp(transform.position, hovercraftPivot.position, Time.fixedDeltaTime * 80f);

#

Now about this:

CalculateStabilityInfluence()

#

If I apply force to make the ship move forward and then stop applying it, then proceed to turn the ship, the ship won't change direction like a normal car would because it has no contact with the ground, it will keep going the same way. Now to fix this I added CalculateStabilityInfluence() which rotates the rigid's body velocity to the ship's forward direction by time * some influence value. This way the ship will change direction of movment without appying force at a cost of speed lose

#

But even if I disable the CalculateStabilityInfluence(), something else affects the strafe at high speeds

meager trout
#

I was wanting my player to pick up a ragdoll by a limb, however there's only one slot for a connected body. If I connect it to the player's Rigidbody hand, it goes there but it's no longer connected to the ragdoll. If I connect the player's rigidbody hand to the limb, the limb doesn't seem affected by it. Is there a joint or a method that would connect both of these together, so the dragged limb looks attached to the hand?

timid dove
#

you have to configure everything properly of course

#

the connected body, the anchor position etc

#

Also the objects need to be moving via the physics engine to work properly with the joint

#

you can't teleport them around via Transform or animations or VR rigs etc

meager trout
#

So my CharacterController would be a problem

timid dove
#

yes

#

joints attach rigidbodies to each other

meager trout
#

So I have a Rigidbody in the player hand, it has a joint but its joined to the forearm. The ragdoll has a joint in its hand, which is joined to its forearm. Would I then have to anchor the ragdoll's hand joint to the player's hand joint position?

timid dove
#

you would make a joint that connects the player's hand body to one of the bodies in the ragdoll

meager trout
#

I have Rigidbody.Move() on the ragdoll's hand, which moves it to the position of the player's hand, but as you can imagine it's not exactly smooth, and the limb joints don't exactly stretch out like they would if you were pulling the hand from the body

timid dove
#

the internal connections of each thing don't really matter much

meager trout
#

Oh ok. I tried the connecting the player's hand body from its forearm to the ragdoll's hand, but it didn't work. Which I'm assuming would be due to the CharacterController then

slow shuttle
#

Hi everyone,
I'm looking for a good guy who can help me understanding a rigidbody / animation rigging package issue, is this is the right channel for that ? Thank's

dense spire
#

Hi, currently running into an issue with my player model seemingly getting caught on the terrain (completely flat)

This didn't happen when I was using a capsule for my player, but now that I have imported my own player model, when its moving around it will feel like its getting caught on something (speed instantly reduces to 0 for a frame). When I turn off gravity and permanently set the model to be off the ground, it works fine. Is there something I need to do to my model or the terrain to fix this?

timid dove
dense spire
#

Hmm... Alright I guess.

dense spire
timid dove
#

A capsule is always capsule shaped

dense spire
#

Got it. Guess accurate hitboxes aren't too important for what I'm doing.

#

Thanks for the help

mint surge
#

Anyone know why my character falls through the ground?

#

I’ve got it as rigid body with a mesh collider but it isn’t interacting with anything

#

Wait if it’s an animation does it act the same as an object?

viral beacon
#

does anyone know where I could find the raw code for the physX sphere collider?

timid dove
timid dove
mint surge
#

Sorry basically I meant since I imported it from an animation website would I treat it as if I created a new 3D object

#

Like would the same stuff apply

timid dove
#

i still don't really understand the question

#

collisions are the domain of Rigidbodies and colliders

#

the place you got your art from isn't really relevant

#

and I don't know how you would treat a "new 3D object" so unsure how to answer that

vital crane
#

how would i make a one sided platform tile

vital crane
#

ah

#

thanks

split shale
#

Not sure if this is the best channel to ask this question, but it didn't feel right in scripting areas and does affect my physics.
Inside of Project Settings > Time : I edit the Fixed Timestep to 0.01 instead of the default 0.02 value for more frequent physics updates.
However, whenever I make a build of my game, I don't think it is using that new timestep value but instead the default one, which effects all of my physics including player jump height.
Any ideas why my project settings wouldn't be carrying over into my build? I would really like to be able to use the more frequent timestep.

First obvious silly reason I made sure was that my project was saved before making the build.

inner thistle
#

You've misdiagnosed the problem; even if the timestep was wrong in the build, it wouldn't affect how physics work (that drastically)

#

More likely it's because the build runs faster outside the editor and the code doesn't account for that with deltaTime or it's used wrong

cursive glen
#

Hi guys, I am encountering a problem when setting a rigidbody to be kinematic. I have a car that passes through trigger colliders acting as checkpoints. When I pause and resume the game, the car's rigidbody is set/unset to kinematic. The problem is that changing the rigidbody's isKinematic property while inside a checkpoint (it already got triggered) triggers the checkpoint again. How can I avoid this?

    {
        velocityOnSleep = rb.velocity;
        angularVelocityOnSleep = rb.angularVelocity;
        rb.velocity = Vector3.zero;
        rb.angularVelocity = Vector3.zero;
        rb.isKinematic = true;
    }
    private void WakeUp()
    {
        Rb.velocity = velocityOnSleep;
        Rb.angularVelocity = angularVelocityOnSleep;
        velocityOnSleep = Vector3.zero;
        angularVelocityOnSleep = Vector3.zero;
        Rb.isKinematic = false;
    }
devout token
cursive glen
#

Thanks, I'll try this

dark prawn
split shale
# inner thistle You've misdiagnosed the problem; even if the timestep was wrong in the build, it...

Thanks for the reply, yeah I have been trying to see where else the issue might be and debugging a couple other common areas.
When I switch the timestep back to 0.02 in my editor, it feels identical to my build is the only reason I figured it might be the timestep.
But I wrote a gamemanager script that manually switches the timestep to 0.01 at runtime and that still didn't fix the problem, so I think you are right that the problem lies elsewhere.
I was curious about the multiplying by fixeddeltatime, but I made sure in documentation that I don't have to multiply Time.fixedDeltaTime inside rigidbody.AddForce.
I'll keep checking for other possibilities in my code. At the moment my code is pretty standard jump script that doesn't have any areas that need multiplied by deltaTime or fixedDeltaTime that I can tell. It's all Vectors with speeds that don't apply until rigidbody.addforce() inside of the fixed update which you shouldn't have to multiply by fixedDeltaTime right?

inner thistle
#

"Vectors with speeds" sounds a bit suspicious

#

It would be easier if you showed the scripts related to jumping

devout token
#

You never should multiply by fixedDeltaTime

frank cedar
#

is there a way to freeze rotation every time by default in a 2d game? I keep forgetting to do it sometime and it messed up my sprite

#

and also if I want a immovable boss

#

do I just put the mass really high?

#

or can I make it not movable by other objects?

devout token
silent bronze
#

I have a 2D softbody made of 4 bones each with rigidbodies. I have them all set to interpolate. They're fine when tested in editor but when exported to iphone, they become very jittery. Any idea as to how I can fix this?

split shale
inner thistle
#

Is there some reason why adding the jump force is that complex instead of just rb.AddForce(jumpSpeed * Vector3.up, ForceMode.Impulse)? Not sure if that's causing the problem though

frank cedar
#

for kinematic body, is there an easier way to stand on ground, instead of raycasting and stopping there?

split shale
# inner thistle Is there some reason why adding the jump force is that complex instead of just `...

In regards to zeroing out the velocity.y, I'm doing that so that when the player is falling at a fast rate, the jump just interrupts the fall and the player jumps the normal fixed height rather than just "slowing down by the jump speed amount" if that makes any sense. In regards to all the boolean checks, I imagine I probably have 1 too many and was over complicating that with the "hasJumped" and "isJumping" for example. I wouldn't be surprised there's a bit too much complexity that could be cleaned up there.

inner thistle
#

I don't see anything else that would be obviously wrong there

split shale
cursive glen
upbeat cobalt
#

I have a Rigidbody car and a kinematic character controler. How can i get rid of this behaviour where kinematic character controler is moving cars like a feathers? I want a car to stay rigidbody and dont want to set it to kinematic.

split shale
#

@inner thistle I think I found the fix. I know you never should multiply fixedDeltaTime inside of addforce. But I think because I was doing all of that extra stuff like adding speed to current velocity.y value, that stuff was becoming inaccurate when the FPS changed. (my fps was running around 240 inside the editor, but locked 60 fps in the build)

Adding fixedDeltaTime here made everything feel normal again:

    private void FixedUpdate()
    {
        float jumpSpeed;
        rb.AddTorque(movement * speed);
        rb.AddForce(movementForce * speed * 0.15f);

        if (isJumping)
        {
            jumpSpeed = Mathf.Max(rb.velocity.y + jumpAmount, jumpAmount) * Time.fixedDeltaTime; // Here is the change
            rb.velocity = new Vector3(rb.velocity.x, 0.0f, rb.velocity.z);
            jumpForce = new Vector3(0.0f, jumpSpeed, 0.0f);
            isJumping = false;
            rb.AddForce(jumpForce, ForceMode.Impulse);
        } else if (dropPressed && !isGrounded && rb.velocity.y > - 20.0f)
        {
            rb.AddForce(-Vector3.up * 20.0f, ForceMode.Force);
        }
    }

(In short you were dead on I think about missing a fixedDeltaTime somewhere and a hunch at that area. Thank you!)

upper quest
#

wondering whats happening here

#

the AI is meant to just walk aimlessly towards the PC, thats fine, but i mean the other collision related shenanigans

silent bronze
cedar helm
#

I was told. This is either physics or post processing so here goes: A volume's colliders are interfering with a raycast. But if I set the volume layer to anything but default, the volume stops working. So I can't mask it.

timid dove
#

What kind of volume are you talking about? A postprocessing volume?

cedar helm
#

Yeah a box volume

timid dove
#

If it's a postprocessing volume your real question is not "how do I not use a LayerMask" your question is "how do I make the postprocessing volume keep working when I change its layer"

cedar helm
#

Yeah but I was thinking there was something like Physics.IgnoreCollision but with ray casts I could use as a work around.

cedar helm
#

"Fixed" it. I set the layer to "Ignore Raycast" at runtime. The box volume stop working if you change the layer in the editor so that's clearly a bug.

timid dove
frosty palm
#

please can someone help me, how can I stop kinematic objects from cliping into each other and kinda meshing together? I dont want them ocupying the same space. they already have colliders, but it doesnt seem to work

arctic hearth
#

The physics system itself seems to behave differently depending on framerate; all of my player movement calculations use time.deltaTime (Minus mouse movement of course) but the player behaves differently at slower/higher framerates?

fringe heron
#

can I change radius of this sphere?

#

it is like one point only, single ray

timid dove
inner palm
#

Hi, have q about physics
How can I simulate physics on some selected or a group of objects ? (without disabling / enabling the other's rigidbody)
Do you have any idea ?

bleak umbra
hasty igloo
#

Is it possible to make rigidbodies immoveable only to specific/layer rigidbodies? Without having either being kinematic, so that A can push B around, but B cannot push A around.

#

Ideally without setting either to a ridiculously high or small mass

timid dove
#

otherwise no

hasty igloo
queen rivet
#

Can you just use 2 rigidbody ?

#

Also, I think we are using 2 collider for our setup here.

#

1 is bigger than the other.

#

Yeah, we have 2 rigidbody and 2 collider on different layer.

#

-> Character [Rigidbody (Non-Kinematic), Collider, Layer=Enemy]
--> InterCharacterCollider [Rigidbody (Kinematic), Collider, Layer=CharacterCollider]

Enemy collide with CharacterCollider
Player do not collider with CharacterCollider

It result in:
Boss can move Player, Player cannot move Boss.

rare juniper
#

How do devs commonly handle hit reg when the local client model is just floating arms but the remote model is a full humanoid? How do you ensure the floating arms line up with the remote humanoid model so that hit reg is accurate?

dense spire
#

Hi! Currently working on redoing the camera/movement system for the game I am making.

Trying to make the camera always look at the character on the y axis(imagine something like dead by daylights camera system).

Tried a bunch of different inputs for the y rotation, but can't seem to find one that works. Any suggestions?

        float mouseX = Input.GetAxisRaw("Mouse X");// * Time.deltaTime * sensX;
        float mouseY = Input.GetAxisRaw("Mouse Y");// * Time.deltaTime * sensY;
        yRotation += mouseX;
        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, 0f, 25f);
playerCam.transform.rotation = Quaternion.Euler(xRotation, **?**, 0);
timid dove
real obsidian
dense spire
inland jetty
#

I have a scenario where i dont know why the mass of an object has no affect on a collision. I have a spinning object that rotates around a point, so it swings up/down and hits the player, the player gets tossed. The fixed point is a kinematic rb, the golf club is attached via fixed joint. I wanted to customize how far it hit the player based on the golf clubs mass but its just not affecting anything

1 thing I noticed was setting it extremely low like less than 1 made me not move as much, but a mass of 1 and 999999 had the same outcome, as in my player reached pretty much the same distance/velocity

How can I set this up so mass matters?

rich trench
#

Hello, I have an issue in my 2D game. I implemented a ledge grab which works with 2 collisions : one to detect the ledge to grab, and another one which verify that there is no "Ledge" layer above (so the player will grab the ledge at it's top). When I jump it's working pretty well, however if my character is too fast (-20 y velocity is the max), the box starts bugging and will sometimes detect the ledge and sometimes not. Does someone know how to fix this ? https://streamable.com/wfhc7k

broken zinc
#

can anyone help me understand how to use the drive forces in the configurable joint? like what values are and arent in world space, does it matter which object has the joint and which is the connectedbody, how are the forces apply to both objects?

#

the documentation doesnt have much info

timid dove
broken zinc
timid dove
#

what are you trying to accomplish

stiff tinsel
#

im new to unity and im trying to make a ball fall onto a plat form without going through it, unity is saying i need to turn kinematic on for it to not go through it but when i do turn it on it doesnt move

tawny raft
#

oh ok just add a circlke collider/sphere collider to the ball (2d/3d respectively same with the box, but for square/cube, and turn off kinematico n the rigidbodyu @stiff tinsel

timid dove
#

not sure what you mean by "unity is saying i need to turn kinematic on for it to not go through"

stiff tinsel
tawny raft
#

click add component

#

search sphere collider

broken zinc
# timid dove what are you trying to accomplish

im making a mod for blade and sorcery so im having to work with their system. i dont know if applying forces to one object is necessary but i dont know how i want to approach this so im trying to get an understanding of the joints

stiff tinsel
tawny raft
#

dw

#

ull get used to it over time

marsh quarry
subtle sequoia
#

Does anyone know of a way to change the underlying physX restOffset of a collider without pulling out native plugins?

subtle sequoia
#

Essentially I need a way to get a primitive collider to fake deforming in a fairly simple way. Goal is to set contact offset significantly higher and I was hoping to basically stretch out the distance the surface contact force is scaled up over to that whole fake contact offset range. Would heavily prefer to have the physics engine doing this, because otherwise I'm basically going to be reimplementing the surface contact handling in C# just to change one variable which is a waste of cpu time.

#

Worst case if I could get read access to it I could at least do some faking of things by modifing the separation distance in modifycontactevent but afaik the restoffsets are different based on the colliders being used so I can't really use a const.

subtle sequoia
# devout token Deform in what way exactly?

Say I have a sphere of radius 1, I would reduce the collider radius to 0.7 and leave mesh at 1.0 and also set collision offset on collider to 0.3. The behaviour I want is to get a small amount of the collision force to start occurring when the sphere is 1.0 away from the surface and ramp up to a normal collision force once at 0.7.

#

I dont actually need a mesh on this ofc, the only thing I really need is for it to reach equilibrium a bit away from the collider.

devout token
# subtle sequoia Say I have a sphere of radius 1, I would reduce the collider radius to 0.7 and l...

That'd be a pretty interesting effect
I don't know a huge deal about unity's physics but I've never seen a way to do a "partial" collision, either the contact happens and forces get transferred or it doesn't
Maybe there's something you can do with these
https://docs.unity3d.com/ScriptReference/ModifiableContactPair.html but if not then you'll probably have to code in forces that resemble a kind of soft collision

subtle sequoia
#

Yeah using those atm, but technically the collisions are always partial since the engine does ramp up the collision force as distance decreases to make things smoother.

#

basically I'm spoofing the separation value with that event to try and trick it to applying the force I want it to but it's very very sensitive

subtle sequoia
#

Seperation between colliders

#

if you have contact offset of 5 or something, the contact is generated at 5 units away from surface, but that contact does not start applying force until about 0.1 units away, and that force increases until the surfaces are in contact.

#

the 0.1 value is related to the restoffset, which is another value defined alongside contactoffset in physX that isn't directly accessible through unity api (in any way I can find at least)

devout token
#

I see, so colliders are more like signed distance fields functionally?

subtle sequoia
#

Afaik it's a combination, the slowing down force is there to allow things to be stable on top of eachother since otherwise the contact force would constantly be flipping on and off

devout token
#

Also sounds like it should be technically very easy to allow for squishy colliders UnityChanThink

civic wave
#

hello, i am creating a car game in unity and i've just made a car controller that follows a torque curve, has gears etc. and my question is on how i can get it to drift? i want it to be more realistic drifting than arcade drifting. i'm using wheel colliders, so i've tried making the extremum slip value less, which causes it to drift, but it is too "arcadey"

thorn pond
#

If I wanted to make a cart that I could put items into and drag along, how would I go about doing that?

timid dove
#

that's pretty much it

umbral anvil
#

hi guys any one have an idea how to split a line renderer lazer reflection into pultiple lines? like this?

timid dove
umbral anvil
#

its difficult ... instatiating 3 line renderers at the lazer hit point how to keep threr start point at the same position as the reflection hit point position ?

timid dove
floral wraith
#

Are there any rumour or knowledge about HAVOK getting support for object-oriented projects?

daring terrace
#

Hi! I am currently learning about configurable joints (and how to use them to stab rigidbodies), and I'm having a slight problem. As the video showcases, when testing the two objects, only the long beam is able to pass through (whilst jittering), and the dagger cannot penetrate at all. While the issue may in my script, I think the issue may be the connected anchor.
I'm trying to replicate a system shown in the image above. The solution was to apply the config joint at the green sphere (which starts at the tip of the sword and moves with the contact point); however, I don't know how I can implement this. If anyone has any tips or can point me in the right direction, that would be amazing! Thank you!

viral beacon
#

does anyone know how to compute the resistance to angular acceleration from a collider in contact with a surface depending on its friction

bleak umbra
# viral beacon does anyone know how to compute the resistance to angular acceleration from a co...

Rolling resistance, sometimes called rolling friction or rolling drag, is the force resisting the motion when a body (such as a ball, tire, or wheel) rolls on a surface. It is mainly caused by non-elastic effects; that is, not all the energy needed for deformation (or movement) of the wheel, roadbed, etc., is recovered when the pressure is remov...

mint surge
#

Anyone know why my mesh keeps falling through the ground even though I’ve just made a sphere and it doesn’t fall?

#

Nvm I worked it out

dusty ermine
#

hey guys! Is it possible to see the physics 3d colliders in the Scene view all the time without manually selecting an object?
Thank you in advance!

timid dove
viral beacon
dusty ermine
steel raven
#

How do i stop longer rigidbodies from rocking back and forth when they land on the ground? For example, when a crowbar hits the ground it rocks back and forth like a seesaw. I have the physics material set to 0 bounciness but it still happens.

timid dove
timid dove
#

Kinda looks like you have a capsule collider on it

steel raven
#

There is a capsule collider on it and 2 box colliders

timid dove
#

Remove the capsule

#

That's why it's rolling

#

I'd use 2-3 box colliders

steel raven
timid dove
#

Yes it's because of the capsule shape

steel raven
#

I have tried without capsules and it did not solve the issue

bleak umbra
timid dove
steel raven
#

Its on all long objects, not just the crowbar

timid dove
steel raven
#

I still have the capsule colliders because changing them did not work

timid dove
#

I'm assuming the large box is a trigger?

steel raven
#

yes

timid dove
steel raven
#

If it is just one box it fixes the rocking, though the ends of the object clip through the ground.

median gull
#

I think this is the right place, if not please lmk:
I've tried to do a number of things like scaling objects to simulate growth over time as well as just grabbing and holding the transfrom of a ragdoll. Whenever I do anything with the transforms like that, the bones act like there's nothing holding them together and just drift off. Any help is deeply appreciated

timid dove
median gull
# timid dove present some context here? What are you trying to do?

Thanks for responding! An exact example would be this:
https://www.youtube.com/watch?v=W3x143cYF88&t=197s
I followed this video to the T and it works great. So the end resutl is a rigged sprint with physics. My problem is I wanted to make the jelly balls grow with time, which isn't difficult to do. However, with the jelly balls, whenever you change their transforms/scales, they just sort of fall apart, like their spring joints arent holding anything together anymore

Soft Body 2D Tutorial Jelly Effect - Unity (Easy)

Tutorial from Binary Lunar: https://youtu.be/H4MTeKT0QFY

Music used in this video

Boogie My Woogie no copyright Piano Boogie, royalty free 1940s Swing
royalty free Music by Giorgio Di Campo for FreeSound Musi...

▶ Play video
#

but the second the growing stops, it immediately goes rigid again

wind lagoon
#

I need help!!! I have a platform which moves using a timeline. I have a player using a character controller. When the player steps on the platform, it childs the player to the platform in runtime. But then the player doesn't move with the moving platform aNd I dON'T KNOW WHY!!!!

timid dove
devout token
steel raven
daring terrace
#

Hi! If you're referring to the movement system in Gorilla Tag, I think you should check out the video links I'm sending. One of them outlines a controller script that allows for movement like that, and the other will showcase how to recreate the arms AND 'bounciness.' If you'd like to create your own script, you should check out "PID" controllers and Hookes Law. One of the videos has a discord server linked with a PID script ready, if you'd rather copy/paste. Hope this helps!

#

Wishlist Project Impulse on Steam: https://store.steampowered.com/app/1916360/Project_Impulse/
Discord Link: https://discord.gg/gqVh8FG3ss
David Wu's Paper: https://bit.ly/31dPIpd

I'm going to be showing how I did my physics based hands and climbing for my upcoming game. I used David Wu’s Stable Backwards PD Controller to control the hands mov...

▶ Play video

Set up a VR project: https://youtu.be/yxMzAw2Sg5w

Modell: https://www.mixamo.com/#/?page=1&type=Character
Modellname: Mannequin

Discord: https://discord.gg/r8tjCUUHxK

Chapters:
intro 0:00
core principle 0:35
modell setup 1:25
ragdoll setup 5:15
code 10:24
outro 16:40

▶ Play video
hollow echo
timid dove
#

Damn vertx was too fast

hollow echo
#

Doesn't hurt to double down and confirm 😉

rare slate
#

so how do i fix stepClimb()?

timid dove
#

what's it supposed to do?

rare slate
timid dove
#

I'd probably start by making sure you're actually on stairs before doing it

rare slate
#

i am using a rigidbody controller

timid dove
#

clearly

timid dove
# rare slate climb stairs

I think the simplest approach for stairs with a Rigidbody controller is to simply use a ramp-shaped collider

#

rather than an actually jagged stair-shaped collider

hollow echo
#

You can also look into how to properly make a kinematic rigidbody character controller so you don't have to deal with rigidbody jank imo.
There are also prebuilt controllers that handle all of these things and can be customised too. By going kinematic all of these things are controlled much more formally so you can't possibly introduce bounciness like what happens when you quickly stop or bump into stuff. It does mean you've got to have a different approach when programming dynamic responses to things, but it's ultimately less painful

#

Can depend on the game and what you want to do though so it's not a "100% do this" sort of thing

rare slate
hollow echo
#

Investigating how players move in games with Unity.
Try out the demo at https://nickmaltbie.com/OpenKCC
GitHub project at https://github.com/nicholas-maltbie/OpenKCC

OpenKCC Series Playlist - https://youtube.com/playlist?list=PLFlu9cd6nGXt64a-N063t5hZdpjdIl76p

How a player moves through a virtual space is not always clear and straightforward. ...

▶ Play video
rare slate
#

i cant seem to find the code

#

how do i make it kinematic?

mint vault
rare slate
#

what code do i modify to make it move?

mint vault
half sky
#

https://gyazo.com/6bb054b20071c10bc9b511f4af7dc315

Hey guys, I made a boat for my player and they both use rigidbodies. The player becomes a child of the boat and ONLY the boat moves. Yet this is happening and I dont know why. (The boat is a clone so it acts weird but if I use the normal original gameobject it reacts perfectly normal) I spent the past few days on this and I have no idea how to fix it

The video basically shows that the player does not follow properly the boat. if the boat moves 100m for example, the player will move 20m

If i literally enable the original gameobject before i press play, the boat works properly but if I set it active DURING the game, it breaks and acts like in the video. I have 0 idea how to fix this

#

I tried to enable kinematics to disable the rigidbody and that works when I enable the object or keep is on before I press PLAY but it does NOT work when the boat is created after play (even though the rigidbody is still becoming kinematics)

rare slate
#

hello?

inland jetty
# rare slate hello?

honestly i doubt anyones gonna be going through 250 lines of your code to debug for you which part is causing this. you really should just throw some debugs in there and see whats causing your player to move up. Theres like 8 different places you are moving the rigidbody

candid sparrow
#

Can anyone help me with making the ball fly higher the further I pull back? It's not working as expected in my project.

#

ballcontroller help

mint surge
#

I've got a plane model but it leans back and then falls backwards is there anyway to keep it in one position?

stuck bay
#

Is there a rigidbody setting that has clipping but disables transfer of energy so that rbs cannot push/be pushed by each other?

devout token
stuck bay
#

If I run into you, I will be stopped without moving you, if you run into me, you will be stopped without moving me

#

as if each rb pretends that every other rb is static

#

like you know in a lot of mp games how players can block each other, but cannot move each other

#

(i know according to physics that decelerating something technically counts as "moving" it)

steep shard
#

Hi i was trying to make my first car Controller Script, so i decided to follow a youtube tutorial the thing is i had to make the radiaus of the wheel colliders smaller so that the car whould touch the plane and also i m having this bug where when i acelerate the car turn always to the same direction and i cant understand why...
in the tutorials i m whatching what they do seems pretty hard to mess up but somehow my car turns. I made the car from scracth but i dont think that anything is missing. I only have this one script attached to the car. Can some one help me understand whats wrong. ty!!

inland jetty
stuck bay
dim fulcrum
#

I'm trying to do path prediction for a thrown projectile, Tried a simulated scene but was getting different results, and since my movement is simple I'm now simulating "by hand" calculating velocities and positions, my only problem now is in my simulation version, I'm checking if I hit a target with Physics.BoxOverlap, while the actual object is using OnTriggerEnter, While moving the objects in sync by simulating in FixedUpdate, I can see my simulated object registers the box overlap earlier than the simulated physics object? Does that sound right? Is there a way to better match the actual physics simulation behaviour? (If it was the other way around, that my simulated object was "late" and registering the hit later than the real simulation I was planning to swap my BoxOverlap for BoxCast, but since it's early I don't think it's going to help...

maiden root
#

Hello I'm using the unity tilemap gameobject brush and each gameobject is a plane with a mesh collider for my floor

#

when the player which has a sphere collider moves on it it randomly moves it around and I dont understand why

#
rb.AddForce(movementDirection * movementForce, ForceMode.VelocityChange);

player moves like this and when I stop moving it moves in random directions for a bit then stops

#

this didn't happen before when my floor was just one massive plane

dim fulcrum
#

Sounds like it's a result of interaction with the tiles, did you try making the tile colliders static?

hushed egret
#

Why is it that when I insert an animator controller into the animator, the character half falls under the platform?

#

without animator controller

timid dove
hushed egret
timid dove
#

modify your animation

hushed egret
hushed egret
viral beacon
#

is it possible to use addtorque multiple times and not losing the effect of drag?

#

Ive noticed that if you addtorque twice, the second operation does acceleration completely ignoring drag

#

its screwing up some of my computations, since I want an object that adds torque to itself, while receiving forces from another object.

maiden root
maiden root
#

I think it's because of the plane mesh colliders overlapping? but idk why they all have the same Y coordinate and same size perfectly next to each other

dim fulcrum
#

I'm still new to physics in unity, but I did have mixed results with plane meshes, if you're up for trying random stuff I'd try giving them box colliders instead, lining the top with the tile.

maiden root
#

I tried that too and still the same

shut tendon
timid dove
errant umbra
#

Does anyone know any existing solution to cut softbody meshes (like tearing). Obi PDB solutions don’t support mesh cut due to shape matching high cost and rematching in real time seems to be really hard to make. I got the recommendation to tetrahedralize the unity meshes but I found nothing for unity excepting using external programs like fTetWild + GMS. I saw a C++ repo of nvidia flex but it’s not compiling so I can’t really check how it actually works. Any idea?

robust sail
#

I don't know how to fix this error. And when I start the game the airplane fell into the void, idk why the plane doesn't stop it. Both of them have mesh filter, mesh collider and mesh render.

timid dove
#

also your use of the word "plane" here is kind of hilariously ambiguous

robust sail
#

how can i make it kinematic?

timid dove
#

you can't use a concave mesh collider on the airplane

#

you need to change the collider(s)

robust sail
#

oh ok i didn't kwon that

#

thanks

#

yeah it works

fringe heron
#

when I hit play, one side of wheels are rotated, why?? Wheel collider's meshes

#

this is how it should be:

#

can you help please?

#

this is hierarchy:

timid dove
fringe heron
#

Yep

#

that is correct

#

but I get

#

first image

#

when in play mode

timid dove
#

one solution is put the renderer on a child and rotate it

fringe heron
#

you mean parent is empty

#

and child has renderer

#

and rotate parent

timid dove
#

rotate parent with the WheelCollider pose thing

fringe heron
timid dove
#

rotate child manually in the scene relative to its parent

fringe heron
#

Yes I did that

#

look this is parent

#

this is tire

#

and it has children meshes too

timid dove
#

but what is the code posing?

fringe heron
#

code posing?

#

1 m

timid dove
#

myWheelCollider.GetWorldPose or whatever

#

what are you assigning that pose to

fringe heron
#

wheel mesh is parent

#

empty

timid dove
#

(btw you can use _wheelMesh.SetPositionAndRotation(pos, rot); it will be slightly faster)

timid dove
fringe heron
#

tire is rotated

#

one thing I notice is that

#

some tires have y -90

#

some y 90

#

and I think it snaps to 90 or -90 only

timid dove
#

wdym by snapping?

fringe heron
#

I mean it rotates like this

timid dove
#

aren't you just setting it manually?

fringe heron
fringe heron
#

when I go into play mode

#

it rotates one side of wheels

timid dove
#

right so

#

rotate Tire on that one side the opposite way in the scene

#

and it should be sorted

fringe heron
#

I did

#

but

#

it is like this noiw

timid dove
#

you want 180 degrees

#

not 90

fringe heron
#

When 180

#

and in scene it is like this

#

I think there is some kind of orientation mistake

#

so it depends on global maybe and ignores locally set rotations

#

Thank you for your time, I will recreate hierarchy of it. maybe some weird mistake

timid dove
#

should work

fringe heron
#

Thanks, it worked!)

shy acorn
#

Hey, I am trying to work with Configurable Joints to recreate a gorilla tag type movement that can also grip onto objects, I have everything setup including the gripping feature. However, my configurable joints that allow me to walk around have this odd springiness to it that makes it hard to move, how can I make it more rigid? Right now, my script just moves the target position and target rotation of the joint to the players respective hand.

#

I've tried increasing the weight of the hands which does help but it makes any objects you whack or grab onto OBSCENELY light, and making those objects heavier doesnt seem to help much.

shy acorn
#

So, what can I try?

maiden root
#

does anyone know what could be causing this?

#

it's fixed when I unfreeze the rotation of the box's rigidbody

#

it just goes through the floor and moves around for no reason I can think of

timid dove
lofty patrol
#

Cogs has kinematic rigidbodies and player a dynamic one, both has colliders, how can I prevent the after-force on the player? I tried setting the player rigidboyd force and velocity to 0 when touching ground but still the same and there is nothing on the code that affects any movement on collision with the cog's collider or any other colliders

lofty patrol
quartz wyvern
#

how can we have a 2D circle collider but in XZ plane

#

sphere collider is fine but i need a flat circle

timid dove
#

if you want to use 2D physics components that is your only option

#

what are you trying to accomplish

quartz wyvern
#

i want to ray cast on to a circle collider in my 3d world that is on the floor surface

#

or rather just above the floor surface

#

a sphere obstructs other colliders so i cant use that

timid dove
final kraken
#

hey how would you get the normal vector of a sphere with a just the sphere and another part

mild thicket
#

i think this is the right place to share this issue. I'm trying to work with some wheel colliders but I can't move forward from stop unless I reverse beforehand. Not really sure what the issue could be

timid dove
faint jungle
#

is there a good way to make a 1 way platform so that it does not register collision on the sides at all?

timid dove
#

In 2d you can use an edge collider with a platform effector

faint jungle
#

2D

#

edge collider?

#

ohhhh

#

tyvm

faint jungle
#

is there any way to define that for tiles? when I try to make a custom physics shape for tiles, it seems to only let me make polygon colliders.

viral beacon
#

is there a version of collision.impulse that gets the rolling resistance torque?

timid dove
#

So I would try...

  • calculate the force from the impulse (the docs explain this small calculation)
  • project the force along the plane of the surface to get only the friction part
  • multiply that force by the radius of the wheel to get the torque?
viral beacon
#

It seems odd that it would give a linear impulse but not an angular one

timid dove
#

well there is no angular impulse

#

torque is an emergent property of linear forces being applied at a distance over a fulcrum

#

also rolling resistance isn't really fully simulated in unity. At most you get a friction force. But rolling resistance basically has to do with deformation of tires and other things lioke that that are too complex to be simulated

viral beacon
#

I remember once someone pulled up the physX spring equation, can someone tell me where I could find that?

noble crown
#

using unity's ragdoll tool messed up my rigging, and moved the joints to the wrong places

#

it moved them to the center of their respective limbs

timid dove
light cradle
#

hey, this is way stronger after build: enemyRb.AddRelativeForce (500, 0, 0, ForceMode.Impulse); why does this happen?

timid dove
#

physics should only happen in FixedUpdate

#

Otherwise, faster framerate => more updates => more force

light cradle
timid dove
light cradle
# timid dove show the code
{ 
                      damageCenter = attackCenter.transform.position;
                   Collider[] hitColliders = Physics.OverlapSphere(damageCenter, radius);
                   foreach (var hitCollider in hitColliders)
                   {
                       IHealth health = hitCollider.GetComponentInParent<IHealth>();
                       if (hitCollider.gameObject.tag == "Enemy")
                       {
                            enemy = hitCollider.gameObject;
                          if (health != null)       
                       {
                            health.GetDamage(damage);
                            rb = enemy.GetComponentInParent<Rigidbody>();
                            rb.AddRelativeForce (side, 0, 0, ForceMode.Impulse);   <-- here
                       }
                       }        
                   }
   
}                         ```
timid dove
#

also that formatting is 😵‍💫

#

Please share in a paste site

#

!code

#

I cannot download files on this computer

light cradle
#

ok idk

#

never used a site for that before soo

timid dove
#

where are hitAction1 and hitAction2 called from?

light cradle
#

from an animation?

#

has nothing to do with the physics tho

timid dove
#

It could have, if that was being called in an Update function somewhere else for example

light cradle
#

but that wouldn't change it

timid dove
#

it would

#

more calls to AddForce == more force

light cradle
#

it's just calling a function not more

light cradle
timid dove
#

yes I know you said that

#

I was verifying

#

people say things all the time on here that turn out not to be true. Don't take it personally

light cradle
timid dove
#

I'm not sure then. How different is it?

light cradle
#

like twice

timid dove
#

Could it just be a perception thing based on the game resolution?

#

I would make a development build, add logs or attach a debugger and make sure it's only running once

light cradle
#

ok

#

nope only called once

timid dove
#

then perhaps something else is different?

#

maybe there's an object that is or isn't being collided with?

viral beacon
#

Im trying to use the formula listed in the physX docs for calculating spring force
rate * (targetPosition - position) + damping * ( targetVelocity - velocity);

from my tests it seems that the damping value has half the effect its supposed to, and im not sure why.

paper musk
#

can unity work as a physics engine

timid dove
#

a few of them actually

#

it is not, in and of itself, a physics engine

paper musk
#

oh niceee

viral beacon
#

When I set the damping on a spring joint to 0, it does not infinitely oscillate

#

it seems like a base damping of springrate * fixedTimeStep is pretty close

#

now im only off by about .001

stoic lynx
#

Hey guys, im not sure if this is the correct location but i really needed some help with a model i was working on 😦

hollow echo
stoic lynx
#

i think so :X, springbones and warnings coming up reguarding roots and bones

#

does that count?

hollow echo
#

Sounds like an #🔀┃art-asset-workflow problem. And you should ask your question there instead of getting people to ask you what's wrong.

stoic lynx
#

i am new here and wasnt sure the correct location. thanks ill ask there

sweet sorrel
#

Dear Unity community, I have a scene with a lot of zombies roaming around on a Navmesh, for some unclear reason, sometimes, some agent jitter rotationally when arrived at their location. When I turn off the NavMeshAgent component, they stop jittering. Does anyone have any experience with this "jitter"? I have tried a multitude of different setting on the agent and the navmesh itself, but that seems to have no influence at all.

https://gyazo.com/317aa518b0993300e4c5f6351b1e4b4f

An example of the jitter 🙂

Thanks!

rich whale
#

I want to make a vault or ledge-grab function for my FPS.
I made some simple animation via unity, attached an animator on my Player. and I use script directly let animator play those ledge animation.
I mean, it works, after I set rigidbody's interplation to inter or extra. If set to none, the player won't move, but it's camera animation still works.

#

I just wonder why i need to toggle on rb's interpolation to make this works

#

kind of busy now, i would like to add some vid later

viral beacon
#

does unity have a struct/class for handling rigidbody physics manually? Would I be able to just create a script instance of a rigidbody and modify it?

viral beacon
#

This seems to not quite be what im looking for. I am pretty much handling collision forces completely manually, I just need a medium to treat as a script sided rigidbody.

bleak umbra
#

Any kind of kinematic rigidbody is to some degree a custom physics engine when moved by your own scripts

viral beacon
#

Im using a trigger as a collision bounds, and Im taking the contact point and feeding it through an equation representing my desired shape to get my collision force, then applying it to the simulated body. All for the sake of making my own wheel collider, so certain forces are being applied to a real rigidbody representing the chassis.

bleak umbra
#

Maybe explain more what you need

#

and what are you are missing to do that?

viral beacon
#

Right now all of my variables like the simulated body's velocity, position, etc are in this one script, I feel like it would benefit me to create a more abstract environment for these values so im hoping to make whats essentially a script sided Rigidbody.

Im not sure how to handle the simulation lifecycle, whether I should have a manual trigger like a Simulate() method. Overall I was just asking if unity had something like this already. If not Ill just go about it.

#

I also have expressions for calculating the acceleration caused by forces so I could package those in the simulation environment too

viral beacon
#

does having the simulation mode equal to script disable all scene simulation?

bleak umbra
viral beacon
#

ah, I need this to run parallel to scene physics so I guess ill just go with the custom rigidbody idea

#

also using a custom script instance makes it so that I dont need child gameobjects for the script to work

viral beacon
#

is there a way I can see how "Physics.ComputePenetration" works? Ive been browsing the physx docs for a while and cant seem to find it.

mighty peak
#

Hey, I had a project in unity 2021.3.10f1 and i have upgraded it to the 22 lts version that has just been come up. It seems to have upgraded the colliders, Before it, we couldn't see an option named as PROVIDE CONTACTS. Now it has another bool "Provide Contacts". This makes me think that something has be changed, but after the version upgrade, the project's colliders are messing everything up they have resized and are getting stuck in each other, all the animations are now just some jerks. Can anyone help with something?

timid dove
elfin heart
#

Guys. I'm using a rigidbody controller with a capsule. But I have a problem where I slide off edges. Anyone know I could fix it?

viral beacon
#

What do people mean when they use the term "proxy shape" for a shape related to collision?

timid dove
viral beacon
#

ah, okay thanks

split solar
#

I'd like to write a tool that can take a complex prop mesh that could be concave, and split it into multiple convex collision meshes that I can pop into Mesh Colliders. How could I do that?

#

The idea would be to do it at development time and save the colliders into an asset

#

I'd rather implement it myself but I have no idea where to begin

stiff roost
#

How could i measure the aceleration on a Rigidbody without knowing the force value

timid dove
#

So just subtract the old velocity from the new and divide by the time between them

golden crane
#

Soooo, I have like 2000 rigidbodies and I have this code, modifiying their velocity and rotation every fixed update.
this code take 3ms on my machine which is unacceptable considering the physics system also take around 3ms to simulate them.
Is there a way to optimize this?

timid dove
golden crane
#

UwU all roads lead to DOTS, I was trying to avoid it as much as I can but.... even the new physics event doesn't cut it

zinc aspen
#

Is there a way to reduce the impact of the Physics2D on the performance if there are many missiles flying around? With 900+ missiles my FPS is barely at 20~30
Each has a trigger Collider2D and a Kinematic Rigidbody2D and I currently have no idea how to optimize this

inner thistle
zinc aspen
#

I see, thanks, I'll take a look into this UnityChanClever

#

Also, a second thing to note is that I've noticed the biggest lag spike when the missiles were concentrated in one place, as if the physics engine was checking collisions between the missiles (missile/missile layer collision is turned off in the project settings, but I suppose it still has to filter them out?) while the enemy missiles need to only look for collisions with one object only - the player.

#

So idk if there is a way to completely turn off collisions between the missiles

hardy gazelle
#

I have a very good momentum based controller and I've been having issues with crevices. i'm talking 0.00000001 wide crevices that get created because of my modular approach to making envoriements. As an example i have a line of perfectly aligned railings that all have absolutely no gaps inbetween colliders as the colliders are literally perfect and on the right there is one big collider.

#

As you can clearly see the player sometimes gets caught up in those crevices and jumps a little bit which results in a very unpleasant player experience and sometimes can lead to the player not being able to jump when they have to

#

The same thing happens on different types of grounds that also have singular colliders to each part and while the player is going at high velocities

golden crane
#

Also is that image component 🤔 why not use sprite renderer?

zinc aspen
golden crane
zinc aspen
golden crane
#

It doesnt matter, as long as u have hundred of ridigbody2d or collider and they r moving your frame is gonna drop.
Try create like 500 rigidbody 2d and collider2d then put them as child to spinning transform, it will become apparent in the profiler

zinc aspen
#

Unless I can tell the difference between one Transform and another, then I could remove the rigidbody

#

Cause right now each missile has it's ID so it can be removed from the Managers Array

#

I could just call the Manager method for the missile from within the players OnTriggerEnter2D instead then

zinc aspen
#

Oh, true

#

But still, I'd have to check hundreds of array elements to find the right instanceID, instead of accessing the item by it's custom ID

#

But it would probably remove the issue with the rigidbody, so I'll try anyways

golden crane
#

If u could use dictionary it will be fast to access large collection

#

<int instance id, data>

zinc aspen
#

Ah, also true, I'll take a look if it's applicable in my case in a minute

#

But there's another issue.
If I use a dictionary then I'll lose the array access to update each missile

#

Unless I just return the control back to the missile

viral beacon
#

Is there a way to have a collider not marked as trigger, so it activates "OnCollisionEnter" and I can access "Collision.contacts" but make the collider not process depenetration forces?

#

I guess marking a rigidbody kinematic does this

#

Oh, it doesnt report contacts while kinematic