#⚛️┃physics

1 messages · Page 2 of 1

dense coyote
#

Tilemap colliders:

#

Player collider:

#

The collision between the player object and the tilemap is not happening, the player just falls trough it

#

remove rigidbody or make put them in different layers

#

or change the rigidbody body typee

timid dove
dense coyote
timid dove
#

do you ahve a script

#

Also note you're using Outline mode on the composite collider

#

and discrete collision detection on the player

#

both of these may contribute to frequent tunneling

dense coyote
#

I do have a script, but it's falling because of the rigidbody2d

dense coyote
#

and should I send the script

timid dove
#

polygons and continuous

timid dove
dense coyote
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    [SerializeField] private float move_speed;
    // [SerializeField] private float jump_strength;
    [SerializeField] private Rigidbody2D rb2D;
    // [SerializeField] private CapsuleCollider2D cc2D;
    // [SerializeField] private BoxCollider2D bc2D;
    // [SerializeField] private LayerMask ground_layer;
    // Start is called before the first frame update

    // Update is called once per frame
    void Update()
    {
        //Jump();
    }

    private void FixedUpdate(){
        Move();
    }

    private void Move(){
        float dirx = Input.GetAxis("Horizontal");
        Vector2 velocity = new Vector2(dirx*move_speed*Time.deltaTime,rb2D.velocity.y);
        rb2D.velocity = velocity;
    }

    // private void Jump(){
    //     if (Input.GetButtonDown("Jump")){
    //         Vector2 velocity = new Vector2(0,jump_strength);
    //         rb2D.velocity+=velocity;
    //     }
    // }
}

dense coyote
timid dove
#

why are you multiplying Time.deltaTime into the speed

#

all that's doing is forcing you to multiply your move_speed by 50

#

anyeway next thing to check is that your tilemap colliders are shaped how you actually expect

#

and that the objects aren't on layers that ignore each other etc

dense coyote
timid dove
#

show the player's collider gizmo

dense coyote
#

i tried using a box collider 2d

#

same result

timid dove
#

and can you show the hierarchy of the player?a are there any parent/children etc

dense coyote
timid dove
#

ah right

#

I mean it should work I think with the stuff you've shown but we must be missing something

#

can you show a video?

dense coyote
#

i can screenshare

#

dont really have any recording software on my pc

#

i think that ive been messing with layers

#

but im sure i havent touched the default layer

timid dove
#

show physics 2d settings screen

#

especially the collision matrix

dense coyote
timid dove
#

the thing at the bottom

#

layer collision matrix

#

is what I wanted to see 😛

dense coyote
#

ah ok

#

soz

timid dove
#

ah

#

see you've disabled almost all collisions

dense coyote
#

oh that

#

ohhhhh

timid dove
#

you said the objects were in the default layer

#

default collides with nothing (not even itself) the way you have it set

dense coyote
#

oh i configured the layers but i didnt set the layers to the objects

#

ohhh

#

so to fix this i need to set the player layer to the player object and the ground layer to the tilemap object right?

timid dove
#

sure

dense coyote
#

thanks dude

timid dove
#

or re-enable default/default collisions

dense coyote
#

appreciate it

obtuse spruce
#

does anyone know any tutorials which could help me make a realistic car controller (this includes: soft-body wheels, suspension, downforce, steering, transmission, handbrake, some hp + torque system, etc)

idk, i think im asking for too much

civic field
#

I want to limit my character's x speed by applying a dragforce only on that axis but I can't seem to get it right

  _rb.AddForce(transform.right * (-Mathf.Abs(_rb.velocity.x) * _playerStats.horizontalDrag));
timid dove
#

you need to project the velocity onto that axis to figure out which part of the velocity is along that axis

jovial wraith
tacit laurel
#

is there a runtime function that decomposes concave mesh collider into colliders primitives?

civic field
#

This works ok based on tachyon's response though i'm not sure about it

_rb.AddForce(Vector2.right * -_rb.velocity.x * _playerStats.horizontalDrag);
warm pilot
#

what's the easiest way to detect terrain/collider contact?

#

my collider cannot be a trigger, it has to keep working as a physics object.

#

I tried the following but I get no results:

#

public class ColorContact : MonoBehaviour {
    public bool inContact;
    private MeshRenderer meshRenderer;

    // Start is called before the first frame update
    void Start() {
        inContact = false;
        meshRenderer = gameObject.GetComponent<MeshRenderer>();
    }

    private void OnCollisionEnter(Collision collision) {
        Debug.Log("OnCollisionEnter");
        foreach(ContactPoint contact in collision.contacts) {
            Debug.DrawRay(contact.point, contact.normal, Color.white);
            if(contact.otherCollider.gameObject.name.Equals("Terrain")) {
                meshRenderer.material.color = new Color(1, 0, 0);
                inContact = true;
            }
        }
    }

    private void OnCollisionExit(Collision collision) {
        Debug.Log("OnCollisionExit");
        meshRenderer.material.color = new Color(1, 1, 1);
        inContact = false;
    }
}
#

every model has a ColorContact

#

at least five parts and more likely 9 should be red and inContact=true.

warm pilot
#

aha. I'm putting the contact test in the wrong place...

lone axle
#

i traspass the colliders sorry i speak spanish

timid dove
weary thicket
#

hi guys , i'm trying to make a lot of coins collide together, but when there are a lot of coins, my fps drops down dramatically. I'm using a mesh collider since there are no primitives to fit a coin, and i read in the docs that mesh colliders require more use of the computer. Is there any tricks you can give me?

unique cave
#

Other than simplifying the mesh, i dont know any good ways to optimize

#

Also could try to make the coin out of few box colliders

weary thicket
#

@unique cave When hitting 100 coins, i start to be under 60fps, than around 180 coins, i drop to 30, with drop to 8 and so.
The mesh is a simple coin with 2 faces for the... big faces, and 24 faces on the edge. I tried to do less faces on the edge and it is not very conclusive.
I tried with a few box colliders too, and it was worst!
Do you know if i can do 2D colliders on the big faces and still use it in 3D? (just an idea)

unique cave
#

Theres no circle collider 3d

weary thicket
#

Yeah, i know, that's the problem :/

unique cave
#

Do you drop the coins in some sort of container or on a plane or?

weary thicket
#

On a plane with 3 sides, include one pushing (like a coin pusher game)

#

and when i have an amount of coins being pushed, it start to drop down fps

unique cave
#

Maybe share a screenshot

weary thicket
unique cave
weary thicket
#

and the coin prefab is simple:

weary thicket
unique cave
#

Then I dont have many suggestions anymore

weary thicket
#

Ok. Thanks anyway 😉

wind quail
#

anyone know how to stop a joint from being affected by objects? so for example my player jumps on a platform fixed on by a joint, but it doesnt make the joint swing etc.

timid dove
#

Are you asking how to make the platform not move?

wind quail
timid dove
#

another option is disable collision between the player and the main platform object, and give the platform a kinematic child object, with which the player actually interacts.

wind quail
carmine basin
#

Not entirely sure where to put this, but i'm trying to rotate using torques for something, and I can't quite get the result i wanted. I've tried rotating using a force multiplier and a slerp in the torque, and i've tried using both the eulers and quaternions in a PID loop, and they always just keep spinning

#

does anyone know what might be better?

bleak umbra
carmine basin
#

I'm trying to get some segments of a blade to follow given points using forces. The positions are followed fine, and I think i got the rotations working now too.
The idea is for the blade to sort of "come apart" when swung, to propel the shards

bleak umbra
carmine basin
#

i'm not sure where it'd fall tbh. I can post a video of the current state of it

#

i hope this shows what im trying to do

#

Im currently having this issue where making the integral parameter of the PID any non-zero number causes all the segments to spin around

desert wharf
#

Hey guys i need help. I have a game where you controll a little square but i am loosing my mind now. 1. Sometimes, randomly when starting the game the fps drops down from 500+ to 100 when moving the player and 2. also randomly when starting the game sometimes the player moves slowly and sometimes fast. WHY IS THIS HAPPENING? I changed nothing in the code but sometimes it happens and sometimes it doesnt...

#

Update: the fps drops are only when i have the player object selected in the editor while playing?

timid dove
desert wharf
#

Already got the one solved, what do you mean by Frame indipendant? Sorry im a bit new

#

Oh I get it

#

Thanks

stuck bay
regal ingot
#

Morning 🙂 Is there an easy way to get my rigidbody character moving over this small incline? When he's walking he collides with it and stops. He only gets over it if he's running.

bleak umbra
regal ingot
versed blaze
stuck bay
#

so i have a character with a really baggy type cloth in blender that needs to be simulated ,, but i don't know how to go about it. should i simulate in unity , in blender? and i'd also really appreciate a tutorial on this topic since i couldn't find any that are remotely close to what i need

timid dove
dapper eagle
#

What is the default friction factor when having no physics material?
Is it 0.6?

midnight geode
#

I'm having issues with a hinge joint rope at the moment, so when the player swings it won't meet a climax and kinda keep going but slowly losing speed as you hold down the arrow key and then when you release it slowly goes back down like there is some sort of resistance, does anyone know why this is happening, thanks!

floral fossil
#

I want to make a nerf gun like projectile in my game, but I'm stuck between spawning physical projectiles to shoot at the target or using a raycast. My thought is that since nerf darts are slower than regular bullets, having damage being dealt before the dart reaches the target would look wonky. Which is better for this situation, or if there's another method tell me

light folio
#

I need help
when i click the particle in the editor window it doesnt auto play and the box that shows up in peoples tutorials wont show up.

sterile light
#

How would I make a rigidbody more "squishy"?

I have an cube that I want to make de-bounce slowly from collisions, almost like a spring or rubber ball, rather than being like a solid metal block. Not neccesarily referring to the bounciness, but the ability to penetrate and de-penetrate surfaces, sort've like skin width on a character controller.

winter jetty
sterile light
winter jetty
#

nvm he actually sets the bouncyness of the ground material

#

just look through the first 10 minutes and it explains it

sterile light
winter jetty
#

your welcome

sterile light
#

That was a very helpful video, but my issue now is that the OnCollisionX methods don't actually detect collisions against concave mesh colliders, which is practically my entire scene, and because I have a fairly detailed environment I'm not sure I can mark everything as convex (and not sure if this would reduce performance or have other weird side effects on the rest of the gameplay?)

Is there another way I could push the player away from walls and any other objects this bounding box around them might overlap with? Would Physics.boxcast or something like that work against concave mesh colliders?

#

Maybe it would be best to create an invisible, solid rigidbody and have a spring join connecting and pulling the player towards it? It just seems difficult to work with and really control the behavior of the collisions 🤔

timid dove
sterile light
# timid dove - OnCollisionXx and Raycasts all work with concave mesh colliders (as long as th...

I see. All of my environment mesh colliders seem to be marked as static for everything except "Contribute Global Illumination", so that should work for detecting collisions then?

I must've missed something else, since the object with the OnCollisionStay script only seems to detect collisions from the player object/collider.

The object with the OnCollisionStay script has a box collider and kinematic rigidbody. It is also a child of the player object, which has its own non-kinematic rigidbody and capsule collider, if that affects anything.

Thank you very much for the help 😁

timid dove
#

OnCollisionXx won't work with kinematic/static or kinematic/kinematic pairs

#

Only OnTriggerXx

sterile light
#

Damn. Okay. And you said box cast would work as well, as an alternative?

#

I might try that since I would like to have things like contact.normal and contact.distance and all. Then if that doesn't work I'll see what I can do with a trigger collider 🙂

desert wharf
#

hey everyone, for some reason my code doesnt work. i wanted to instantiate a bullet and make it look at some position, so it flies towards it. but it spawns rotated in a completely different direction.

#

private void SpawnBullet(Transform posToLook)
{

    Vector3 diff = (posToLook.position - transform.position);
    float angle = Mathf.Atan2(diff.x, diff.y);

    GameObject instance = Instantiate(Bullet, transform.position, Quaternion.Euler(0, 0, angle * Mathf.Rad2Deg));
    
    
    



}
inner thistle
#

That's not really a physics question but

Vector3 diff = posToLook.position - transform.position;
Quaternion rotation = Quaternion.LookRotation(diff);
GameObject instance = Instantiate(Bullet, transform.position, rotation);
bleak umbra
timid dove
#

it's y, x

tiny rapids
#

Hello,

Wanted some advice on custom coded character controller.

Wanted to know the pitfalls of not using rigidbody for it.

With non kinematic bodies
I know collision resolution and physics engine calculations are a great benefit but at times when there are aracady stuff involved, for eg “jump cancelling and in air attacks and hit feedbacks like dmc”

It feels like it would be fighting the framework a bit so would it be or not ? Since non kinematic bodies will receive forces from collisions so how would this go ?

After tons of thinking I am avoiding rigidbody component at all and whatever physics I require im coding them myself (jump/ground detection/gravity)
But what im concerned about is the scalability of it.

I know going custom itself mean everything doing by myself but what im concerned about is it is okay at a larger scale ?
Basically its like I dont know what I dont know and wanna know about problems at larger scale which I would potentially face.

Btw its a heck and slash combat game.
And im using overlap boxes raycasts and static colliders for physics related stuff.

timid dove
# tiny rapids Hello, Wanted some advice on custom coded character controller. Wanted to kno...

The main pitfall I can think of is that you won't be able to get OnCollisionXx or OnTriggerxx callbacks at all without a Rigidbody. You should have a kinematic body at the very least.

It's actually considered bad practice and poor for performance if you have a collider that moves without a Rigidbody. When there's a collider with no Rigidbody, the engine considers that a "static" collider and doesn't expect it to move. It makes certain optimizations around that.

#

In short, I recommend adding a kinematic body

tiny rapids
pine schooner
#

I dont exactly know where to ask fo help with this but does anyone know how to fix the ragdoll?

unique cave
jovial wraith
# pine schooner I dont exactly know where to ask fo help with this but does anyone know how to f...

it looks like your AnimationController is fighting with the physics engine. The AnimationController is directly controlling some parts of your model, which makes them ignore physics. But other parts are not being controlled by the AnimationController (because the animation doesn't have values set for those parts) so physics affects them.

When you want to apply physics, you need to turn off the AnimationController and the ragdoll should work okay.

pine schooner
#

Hmm I might have written it wrong in the script u thought I had done that thank you!

serene forge
#

how do i stop the player from getting bounced up when they stop on a slope?

timid dove
serene forge
#

i dont think its the code

#

this is the controller

timid dove
#

In your fixedUpdate, you use the existing y velocity always

#

your video is just the existing y velocity you had continuing without any x

#

(hence why the "bounce" is smaller on the shallower slope)

serene forge
polar leaf
#

Hi, in my level I need to spawn a ton of rigidbodies, which is hurting the performance a bit. I don't need them to be a rigidbody all the time though, only when close to the player. Will setting them as kinematic help on the performance? (just faking it by modifying the transform when far away from player)

timid dove
#

Or try kinematic, yes

bright elbow
#

Anyone know y the outlineis bigger than the actual thing

#

wasnt sure where to post this

bright elbow
soft glade
#

Hello, asked for help a couple weeks ago but haven't figured out a clear solution for this.

Trying to work with wheels for a car, trying to emulate an old arcadish racing game's suspension, but the wheel collider was giving me issues and I don't know how to tweak its settings to get a similar effect to what I was trying to emulate.

So attempted to make a custom suspension gameobject instead, using two cubes and a sphere with this structure:
-two cubes, connected to each other with a spring joint for suspension, and a configurable joint to lock movement to one local axis.
-The sphere is connected to one of the cubes with a hinge joint.
-The other cube is connected to the car using a fixed joint.

Here's the issue: When I tried to test it by using a PlayerController script that applies torque to the four spheres to make the car roll forward and back, the suspension object's fixed join starts to glitch, spring back and forth, then cascades into what the video shows.

No idea what could be causing that because I set the suspension to not collide with the car through collision layers and there's no other script on the car than the one applying torque on the wheels.

Anyone happens to know what could be causing that and how to fix it?

It's the video I had posted here #⚛️┃physics message

woeful cave
#

why is unity

#

brain hurty

timid dove
#

it has nothing to do with unity

#

just trigonometry

woeful cave
#

bruh dyno lick me bro

rocky pelican
#

he's right tho

#

atan2's params are also 'flipped' in all the other engines / math libs I've used

#

it's just the way it is

rocky pelican
#

some things will never change

polar leaf
#

just lost two hours because apparently changing a rigidbody parent object doesn't work correctly and you should change the rigidbody position directly when you need to do it

#

hope this message helps someone 😛

timid dove
midnight geode
#

when my player attaches to a rope the rope acts odd...when the player swings it will swing in that direction but you can constantly keep going in that direction and when you release the button it slowly brings the rope to the starting position instead of swinging. Does anyone know why this happens and how to fix it?

fresh horizon
#

where do I ask help for code?

midnight geode
wispy patrol
#

Anyone know how I can flip my car upright after it flips on its side or it's back? Perhaps there's even an asset I can use for this?

tepid scroll
#

Hi! I am currently trying to create a waterslide for my game, how do I make the slide actually slippery?

#

keep in mind this is for a VR game

supple sparrow
cinder umbra
#

Hey, im having this weird thing happen. I have a cube as a "floor" i have a capsule that can move, and a cube, all of which are rigidbodies. If the cube and capsule interact, the capsule gains permanent backwards movement. With high friction (on the floor), the speed that the capsule moves back increases, if the friction goes down, the speed the capsule moves back decreases, but the speed the box moves back (when it didnt at all before) increases. Anyone know how to fix this?

cinder umbra
cinder umbra
timid dove
#

I didn't say to leave the channel

cinder umbra
#

Thats what i figured tho since the code fixed it then broke

timid dove
#

Just that your code is causing the issue

cinder umbra
#

I can check my code later, just not right now. I left out some info tho, the capsule moves at 5 units per FixedUpdate() and the cube is .1 units weight and the capsule is 1 unit weight

stuck bay
#

How do I make an object to continue moving after hitting a collider ? It's a Topdown 2D game.

inner thistle
#

Continue moving in the same direction through the collider, or bounce off it?

stuck bay
#

opposite direction

#
        var magnitude = 5;
        // calculate force vector
        var force = transform.position - other.transform.position;
        // normalize force vector to get direction only and trim magnitude
        force.Normalize();
        rb.AddForce(force * magnitude);
#

Im using this code atm.. still trying to get the effect i want

waxen monolith
#

Maybe this is opinion based, but why would anyone use transform.Translate() (except for teleportation, I suppose) when Rigidbody.velocity does the same thing and works with colliders?

waxen monolith
#

I made the mistake of trying to figure out collisions with Translate() and transform.position. Meanwhile, so far Rigidbody.velocity works perfectly.

timid dove
#

it's fine if you don't need physics

bleak umbra
waxen monolith
unique cave
timid dove
#

it ignores collisions

#

MovePosition will respect collisions

unique cave
timid dove
#

And if you're kinematic it will apply appropriate forces to objects in the way

#

it does

#

try it

unique cave
timid dove
#

unless your body is kinematic

unique cave
#

It does, try it 🙄

timid dove
#

if your body is kinematic it ignores collisions anyway (but applies forces to objects in its way appropriately)

timid dove
unique cave
#

Then I have to update my understanding of MovePosition, the documentation page is nothing but clear about that and I have encountered some problems with it earlier

bleak umbra
#

It moves through walls but triggers the collision events

timid dove
#

putting together a quick little video/experiment

#

@unique cave @bleak umbra kinematic bodies go through walls. Dynamics don't. This is all with discrete detection.

bleak umbra
timid dove
#

that's just tunnelling then

#

it's not that MovePosition doesn't respect colliders, it's that Unity collision detection is vulnerable to tunneling in general.

bleak umbra
timid dove
#

in fact even with 1000 speed

#

the 2D dynamic MovePos with continuous detection doesn't tunnel

#

but the 3D one does

bleak umbra
#

That’s would be the behavior I’d expect. What happens if you just set a position on the other side direct?

timid dove
#

rb2D.MovePosition(new Vector2(1000, rb2D.position.y));

#

about to test

#

and rb2D.position = new Vector2(1000, rb2D.position.y);

#

end result

#

MovePosition in 2D physics is really good at not tunnelling 😛

unique cave
# timid dove it doesn't

So it does ignore collision detection mode but doest go thru walls right? Thats what I meant, I phrased it very poorly

timid dove
#

I think it doesn't ignore it, but Unity's 3D continuous detection mode isn't very good

#

2D seems rock solid

bleak umbra
#

does extrapolated and interpolated change anything in the quality of the detection (or whatever they are called)?

timid dove
#

I have to run so I'll need to check later

#

I'd expect not

#

But who knows

bleak umbra
#

apparently the 3d rb has them for performance reasons

unique cave
bleak umbra
#

this one is supposed to be "perfect"

bleak umbra
#

quite pointless though

unique cave
bleak umbra
#

why is it called collision detection then (i used the wrong words above)?

unique cave
timid dove
#

I guess the moral of the story is that if you want MovePosition behavior in 3d that respects collisions at high speed - you have to do your own manual ray/volume casting

#

or maybe you do the math yourself and use velocity, aka do the algebra
d = r*t

#

and set velocity for one frame

unique cave
bleak umbra
#

using a raycast is probably the intuitive thing to do, its such a common pattern

unique cave
#

My point was that I think rb.MovePosition and rb.position doesnt have other differences than visually smoother movement (when interpolation is enabled). Im not entirely sure about that but the docs page seems to suggest the same

#

Im back home tomorrow so maybe I could make little test to see if they are exactly the same

timid dove
#

Or MoveRotation for kinematic paddles in a pinball game as another example

oak topaz
distant iron
distant iron
#

Still expensive

oak topaz
oak topaz
#

i will make a demo

#

on web gl

distant iron
#

Yea

distant iron
oak topaz
oak topaz
oak topaz
#

remembre to change sensitivity at first

#

web gl breaks it

#

so i put to sliders at the bottom right

unique cave
#

Single rigidbody cant do that. Unitys Cloth component is basically a bunch of rigidbodies joined together

#

Cloth vs one rigidbody?

#

Most likely the Cloth component is more optimized than any system that beginners can build themself. Cloth component kinda sucks tho

potent notch
#

if i were you i would also consider looking into stuff like nvidia flex and stuff like that, sure dll interop can seem scary at first, but it is well worth it in my oppinion

#

from testing, it appears to work just as well on amd as on nvidia, although i am uncertain if it will work on phones, i will probably test this tommorrow though

#

the real limiting factors comes from the fact that it only supports cuda and direct x, and some devices you cant use either

#

i wish you luck! You can always simulate soft-ish body simulations using rigidbodies and bones, connected together using springs, although this can get computationally expensive very quickly!

#

good luck with that, if you plan to code it directly i would suggest using compute shaders or/and dots(data oriented technology stack)

#

i wish you luck!

#

compute shaders are basically ways to get the gpu to do stuff

#

welp good luck, and have fun!

cinder umbra
#

Hey, im having this weird thing happen. I have a cube as a "floor" i have a capsule that can move, and a cube, all of which are rigidbodies. If the cube and capsule interact, the capsule gains permanent backwards movement. With high friction (on the floor), the speed that the capsule moves back increases, if the friction goes down, the speed the capsule moves back decreases, but the speed the box moves back (when it didnt at all before) increases. Anyone know how to fix this?

cinder umbra
#

nvm the pill's rotation needed to be locked

spiral escarp
#

hey guys i'm making a 2d platformer and i add force to a rigidbody2d to move horizontally and i set rigidbody's vertical velocity to make it jump can anybody tell me if that's the optimal approach or how i can improve it?

jovial wraith
# spiral escarp hey guys i'm making a 2d platformer and i add force to a rigidbody2d to move hor...

that's backwards from how most people would approach a platformer. If you want really tight horizontal control, AddForce won't work great for you. You'd want to set the horizontal velocity directly and control the logic for how input affects velocity in your own code. AddForce is more okay for jump, but setting the vertical velocity would also be fine. They'd have pretty similar results, though if you're jumping while you already have a vertical velocity (like in a double jump or on a vertically moving platform) they could have different results depending on how you implement the velocity setting one

spiral escarp
vernal owl
#

can anyone help with giving a force field a shape with the same pull graph as gravity and have its size&strength be determined by a variable?
Ideally these force fields would be able to combine like drops of water to become stronger thus allowing pretty accurate simulation of electromagnetism, the strong force and the weak force.

This is all for a particle physics game and all I really know is particle physics

viral ginkgo
#

@vernal owl Could do metaballs maybe?

#

Each force field would be a metaball, they'd attract eachother stronger the closer they are

#

And then they'd merge into a single metaball

#

I think it would look like you'd want it to look

#

There should be shaders out there to achieve this

midnight geode
unique cave
stuck bay
potent notch
stuck bay
#

I had a lot of fun while playing around with the plugin 😆 But when I tried get my hands on it a while back I had to literally scavenge the whole internet for a download so I decided to do this now. Was supposed to upload it sooner, but I forgot 🤣

#

Hopefully someone here will also have some fun with it, or use it for research

potent notch
#

welp great job, as this is awesome, hopefully this should also be super useful for understanding how flex works, as the manual can be quite vague lol

stuck bay
#

It might have a few errors and you might have to delete a couple of scripts, but otherwise it should work fine

#

Whoops. I forgot to mention that in the rep 😆 Better update it

potent notch
#

a few errors is fine lol, compared to the no errors and silent failure that i usually get while trying to get Flex working lol

#

wow checking the version it is actually version 1.2.0 lol

stuck bay
#

I didn't have time to test if I imported the files correctly to github though. But Unity didn't give me any errors when I quickly tried so it should work...?

potent notch
#

oh well, ive got to go to bed soon, but ill try it tommorrow, but looks very promising, great job!

stuck bay
#

Hopefully lol. Git didn't let me throw the whole file on one go so I had to import everything one by one

stuck bay
#

Good luck to you! And if it doesn't import into Unity, just ping me and I'll try to see what's wrong.

potent notch
#

oh also ye it cant be used for commercial stuff i think due to this line in the top of every single file: ```cs
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.

stuck bay
#

Oh. I better add that to the readme file lol

potent notch
#

probably

#

but add a note that nvidia flex in general can be used commercially, just not this specific plugin, meaning if people want to create their own ways of getting nvidia flex working in unity, then feel free

stuck bay
#

Yeah. Also, I don't think NVIDIA minds the distribution, since there were many other places where you could get it that have been up for years so I shouldn't get any legal trouble lol

potent notch
#

ye, plus it is an old version of nvidia flex

#

the latest version of nvidia flex is kept locked up within nvidia omniverse as a part of physx5

stuck bay
#

Updated it.

potent notch
#

awesome!

#

i might try compare the performance from that plugin with the performance of their demo app, could be interesting results!

stuck bay
#

Should spare people from having to research the licensing themselves lol. Thanks!

potent notch
#

lol, welp great job for finding the plugin wherever you did lol

stuck bay
#

Did some more research. NVIDIA doesn't seem to mind the distribution of a download, as long as you don't try to tell people that it's created by you and/or distribute it commercially.

potent notch
#

oh ok nice!

#

hopefully once unity finishes support for nvidia omniverse we will have a proper and more up to date method of using nvidia flex, although who knows how long that will take

stuck bay
#

Ima test it myself to figure out if it can be imported into Unity properly and if you get any errors that stop you from using it

#

I think I did import every file correctly since I didn't get any errors in Unity, but I better open the whole project

potent notch
#

wait nevermind i misread what you said

stuck bay
#

It does seem to open the project at least, let's see if I get any errors once it opens

potent notch
#

welp great job lol!

stuck bay
#

Unity says it has compiler errors (at least in 2021 lts, which was expected). Let's see if it's something that stops you from completely using the plugin.

potent notch
#

we can always use the demo app as a guide if the areas with errors are indecipherable

stuck bay
#

They might be just fixable by deleting the flawed scripts, or at least that's what I did previously to get it working.

potent notch
#

ye, tommorrow im definitely gonna mess around, and do some performance testing, and see what i can get working!

stuck bay
#

Alright! I'll see what kind of errors it has and send them here and to the rep so people are prepared for them.

potent notch
#

ok nice!

unique cave
#

(sorry for being so late) @timid dove @bleak umbra This is the test I made: It's 3 physics scenes running on top of each other, red ones are in scene where the cube is moved using rigidbody.MovePosition, blue with rigidbody.position and green with transform.position. They are all literally the same, there's not even z-fighting happening 🔽 . This is all with non-kinematic rigidbodies (collision detection mode doesn't seem to make any difference in this test, meaning MovePosition doesn't take it into account). When the moving cube is set to kinematic, MovePosition seems to give different results than trans.position and rb.position ⏬ . The argument about moving platforms seems to be true, MovePosition really seems to handle that type of interactions correctly/better but only when the platform is set to kinematic (which is bit counter-intuitive), when it's set dynamic, it's exactly as bad as transform.position

stuck bay
#

Fuck. I imported the packages incorrectly!

#

It only displays a few of the scripts, and doesn't recognize the rest, thus making it unusable

#

I'll try to fix it later, but I'll keep a small break.

#

Added this.

#

Welp, glad I tested it lol. Now people won't download something that won't work

#

Gonna fix it later on.

tropic forge
#

oh no box collider aint 2d...

#

nevermind

#

still not working

unique cave
tropic forge
#

now it works

#

thanks so much

#

and there is no script yet

worthy glacier
#

physics is not physicing

#

how to fix this?

frigid pier
#

@worthy glacier Don't cross-post in other channels. Instead provide proper explanation about what's happening and what you expect.
Guessing about what you mean the problem is here, enabling continuous collision on rigidbody fixes snagging on tilemap colliders

worthy glacier
#

continuous collision is already enabled

frigid pier
#

Are you using tilemap collider for tiles?

worthy glacier
#

i am using box collider

#

i will try tilemap collider

frigid pier
#

Are you using tilemap for this at all?

#

To group regular sprites with own colliders into a single collider object, composite collider should be used

worthy glacier
#

i will relearn basics

midnight geode
stuck bay
#

Started fixing the Flex rep. Should be working within the next 30 mins.

stuck bay
#

Found out that the reposity isn't working because there's something different in 2021 lts and later on versions. I don't have the time to figure out how to fix it today, nor to track down a version that it would work it.

Figured it out by opening the original file, and not the github rep in Unity. Same errors and all.

#

I'll see what I can do tomorrow.

potent notch
#

oh ok got it!

potent notch
stuck bay
#

Yeah, probably. I'll try to get it working. Otherwise I'll just send the folders to git and add instructions on how to add them one by one to Unity.

potent notch
stuck bay
#

You could probably just download the rep and then open your project, and drop the folder titled "Flex" to your project

#

That should work

#

Gonna test that myself once I get home from work.

#

Actually, that might be a better way in general, since you can use it in an already started project, plus I don't think Unity recognizes the Meta files since I didn't import them properly to github. I'll probably just add instructions to drop the Flex file to your projects to the Readme.

#

That is of course if the files in general work

potent notch
potent notch
#

im just really excited to use it as a 2nd reference, so when im building my own solution in unity i have both the demo app and the plugin to guide me on how on earth to make stuff work lol

stuck bay
#

I could probably delete and/or move the assets and such to a different folder to get it working.

potent notch
stuck bay
#

Yep. I'll edit the rep to suit that approach and add some instructions to do so once I get home

potent notch
stuck bay
#

Yep, was planning to do so.

potent notch
#

nice!

stuck bay
#

I also think that it's a very good thing that I'm sharing the package, since some amazing packages such as uFlex are based of it, so maybe we'll get more awesome physics systems now

potent notch
#

ye hopefuly we will get some really nice things with it, one thing im hoping to do is try add temperature based states, so if it is hot then it will become a liquid, and then when cold a solid

#

unfortunately flex does internally reorder the particle arrays for performance, so im going to have to try set up some way to keep track of particles, which i imagine could be both hard and fun!

#

flex does have some reserved phase stuff that i could always use to my advantage to track specific particles, but for multiple particles im currently not quite sure what ill do lol, oh well ill figure something out!

#

also from checking out the plugin's dll interop it is some-what garbage, so im probably gonna see if i can create a better version using clangsharp

stuck bay
#

The plugin in general kinda sucks, even the performance. I had a chance to compare the performance I got with my own bad PC and a bud's gaming PC and it was really similar. I'd get around 15fps and he'd get only 25fps even though he has a modern PC and I have this shit

potent notch
#

ill do a performance test sometime soon and compare the plugin to the demo app, to my garbage first attempt from last week of getting flex working with unity

stuck bay
potent notch
stuck bay
#

But Unity seems to be very very subjective about how it handles performance in different versions

potent notch
#

you should download and try the flex demo app and see if you get better performance, as then we know it is the plugin or unity having issues

stuck bay
#

I haven't played around with flex for about a year at this point so I'm not exactly sure if I could even run it now that Unity's newer versions seem to have worse performance.

potent notch
stuck bay
#

Sure as hell lmfao

#

With the slight expection of models when compared to Nanite

potent notch
#

the one thing i really think need performance improvements would be the particle system though, even with gpu rendering it is still very slow, and cant get more then 10 thousand particles on my computer

stuck bay
#

Did you try it with a render pipeline your PC can't handle, like hdrp?

potent notch
stuck bay
#

Everything default. I pumped up the default particle example to 10m

potent notch
#

fascinating!

stuck bay
#

Nope, the actual GPU one. If I'd have it set to CPU I'd have crashed my PC and broken it once again lol

potent notch
stuck bay
#

This once again shows how subjective Unity is to versions and render pipelines when it comes to performance

potent notch
#

ye

stuck bay
potent notch
#

GTX 750 ti

stuck bay
#

How old is it? If it goes over seven-ish, then it's no wonder.

potent notch
#

same

stuck bay
#

Ah, no wonder it doesn't work that well. The only reason why mine works is that I've fucked around with my PC's settings and also customized the PC in general a bit. I've basically broken every technological limit it should have, and even rendered a whole realtime 4k scene.

potent notch
stuck bay
#

Also, I'm really happy to finally find someone else with slightly worse hardware 😂

potent notch
#

ye it doesnt happen often lol

stuck bay
#

Have you tried dots yet, btw? I got it to run over 10000+ realtime physics objects in 100fps with the new Unity physics, it's amazing

stuck bay
#

Was really awesome to do physics tests with it

potent notch
#

ye same lol, i have a whole sphere rigidbody short puzzle game that i use as a testing ground for it, awesome lol

#

wish nvidia flex was thread safe, as it would be awesome to use dots and flex together for ultimate fluid physics performance lol

stuck bay
#

Hopefully we'll get there, can't wait for Unity PhysX 5 support

potent notch
#

doubt it will come any time soon, the last time i heard there are no physx 5 dll's or anything, instead physx 5 is locked up in nvidia omniverse

#

but omniverse is trying to work with unity to get them to work together

#

hopefully it will come soon!

stuck bay
#

I'd guess it'll take about 1-3 years, but it's sure as hell worth the wait!

potent notch
#

ye probably, very exciting lol

#

physx 5 would be so cool, because it also includes more up to date version of flex and flow, both of which are awesome

#

although i wouldnt be able to use it though lol, rtx and higher only

stuck bay
#

Yeah, that's the only bad part of it lol

potent notch
#

oh well im sure someone will figure out a way to mod that requirement away

stuck bay
#

But maybe ya won't even need it once you played around with Flex enough 😏

potent notch
#

lol

#

that is something i do perhaps want to see, which is faster: Flex, Flow, Cataclysm

#

all of them are nvidia fluid simulation api's from similar times

stuck bay
#

I wonder if I could create a system that would turn Flex water to Alembic animations for water anim creation inside unity

#

I might test that

potent notch
#

ooh that sounds cool lol!

stuck bay
#

But yeah, I'll fix the rep once I get out of work, so in a couple of hours.

potent notch
#

ok got it!

peak cloak
#

So I'm making a game with a wall jump mechanic and I want to make a rope that when the player jumps from the wall and goes back onto the wall there is a rope in his hand that moves with him and his hands go up the rope how can I do that. (ps. Tell me if this is the wrong channel because everywhere I looked ropes seem to be in the physics section)

potent notch
#

i think so, assuming you are using rigidbodies to simulate clothe physics

#

what are you using to simulate the clothes physics?

#

that is the where, but what is the how, cloth physics? Soft body api of some kind? Rigid body?

tidal isle
#

I want to make serialized GameObject array(+-50 items of grid and tilemap). Does it cost a lot of performance? Or maybe it is possible to make it in a better way?

potent notch
tidal isle
potent notch
tidal isle
#

When first game object reaches x position. And destroy game object in 15 seconds

#

On start destroy(.., 15f)

potent notch
tidal isle
#

Wow

#

It will be mobile game

#

But anyway, thanks

#

❤️

potent notch
#

i wish you luck!

lyric urchin
#

Can anyone recommend resources on character controllers? In particular with regards to UX and gamefeel?

#

Other than Jasper's work

tawdry acorn
#

Hey I'm trying to make a drone balance - it is a simple collection of 4 rigidbodies with individual AddForces to simulate a rotor
thing is I don't know a good way to automatically balance the rotation of the drone. Does anyone know a good method? Currently this is what I have, and it sort of works, but it requires a small amount of power (as it will overshoot), and it takes forever to balance and settle

fathom mauve
tawdry acorn
gritty tree
#

when i jump on to this mesh i fall straight through it has a mesh collider but it dosent seem to do anything

stuck bay
#

Started trying to fix the rep. I'll try to just import the folders into a project before I do anything else.

#

I think it should just work if I rename the "assets" folder to something else...? And possibly some other small fixes, but that should be it

#

And of course add instructions for the Editor based stuff

#

Wait, I imported it into an empty project and didn't get any errors. Lemme try to also import the example scenes. Even the editor files worked.

#

Oh wait, I already got the samples! 😂

#

Fuck, it works perfectly! Be it at an awesome fps that is 🤣

#

I do have to say that I did not expect it to work

#

Lemme test around to get some screenshots for the rep so it doesn't look like a virus or a scam before updating it lol

tidal isle
#

Am I using collider on tilemap in the right way?

stuck bay
civic plover
#

anyone good with physic calculations for collisions and detections?

stuck bay
stuck bay
#

@potent notch It should actually work now. Added some instructions and screenshots too.

stuck bay
worthy glacier
#

why is my character stuck on a tile and his velocity is 0

wide nebula
#

Do you ever, in code, set the velocity to zero?

stuck bay
#

You could just animate it in something like Blender, or use Unity cloth physics with a script that adds a physics push to a specific part of the cloth to make it float

unique cave
#

I dont see what the physics would be needed for in this case? There doesnt seem to be any collisions between any objects so no actual physics are needed. It can either be handmade animation or procedural animation which deforms the cloth on the fly (you could rig the cloth so it would have few bones in it and then you could procedurally animate using the players position/velocity, the bones current velocity, nearby bones etc.)

carmine basin
#

I think you might be able to use physics joints for it, but you might have to rely on moving the player using the velocity

#

might be worth looking at configurable joints instead, perhaps? I don't think spring joints allow rotation

#

no worries :)

unique cave
#

With physics its hard to get the cape swaying in the wind/when she runs. You could probably use vertex shader or c# script to get the cape swaying on top of the physics

mint pebble
#

Hi everyone, I'm in a bit of a pickle trying to get my physics to work correctly.
I have a player character which i move using forces. I have other object in the level which also have rigidbodies, but I only want some of the to be able to get pushed by my player. Others should block the collision or be able to get pushed indirectly. Any advice?

carmine basin
#

pretty much. Might be worth looking into something like a water shader for the swaying effect, and then animating or simulating the cape on top of that

haughty scaffold
#

i am very confused lol, is there another proper way to add proper movement to a rigidbody without directly setting velocity?

#

moveposition cancels out addforce which i use for jumping, and using add force for movement gives floaty and unresponsive movement

#

directly setting velocity means that the object will not be able to be pushed by other objects

timid dove
#

If you want things less floaty you add more force over a shorter period

#

Think about how things work in real life

haughty scaffold
#

but using add force means that it doesn’t decelerate when letting go of the key

#

or at least not very fast

timid dove
#

It does if your code tells it to

#

That's why I said be smarter

#

Apply a braking force if you want

haughty scaffold
#

so when the key is let go, for 1 frame apply an opposite force to slow it down?

timid dove
#

I didn't say one frame

#

As much time as you want.

#

Just don't expect you can write one or two lines of movement code and it will feel good

#

Player movement is complicated

haughty scaffold
#

well i know that

timid dove
#

And it takes a lot of tweaking and clever code to make it feel right

carmine basin
#

I once worked with velocities and moving things. It's not ideal if you want to be pushed, but you can make it so it only applies your velocity when you're pressing the movement keys

#

I usually just move the transform directly :P

ruby moth
#

I need some help in my game if someone is available

wide nebula
ruby moth
#

Alright. The thing is my game has a ship and an outside world, when the ship is moved using Rigidbody2D.velocity all items are launched around the ship. Is it possible to seperate somehow so they're not affected from the outside world? I can change the ship transform.position property to move the ship smoothly without items flying but then collisions don't work with the world tiles.

timid dove
#

basically simulate the physics of the inside of the ship in a different scene, and render them here with proxy objects.

ruby moth
#

Thank you

#

This makes sense

polar leaf
#

Are rigidbody forces applied all at the same time for a frame? Or in sequence?

unique cave
polar leaf
#

I'm using add force at position. So if the rigidbody position changes, the torque direction will change.

unique cave
# polar leaf I'm using add force at position. So if the rigidbody position changes, the torqu...

Afaik, the position doesnt change, all the forces from the frame are added up and the position is changed only after the (physics) frame. This should be easy to test. If you add force to the center of mass, there should be no rotational acceleration right? If you add lets say 10 forces to the initial middle position (same position for all 10 calls), there should be rotational acceleration if the position changes after each AddForceAtPosition, if the position doesnt change as I think, the rotation should stay fixed

polar leaf
#

Thanks, I'll try that

timid dove
timid dove
#

move your objects via the rigidbody

#

instead of teleporting them via the Transform

polar leaf
#

Thanks @timid dove

#

I was testing another script. This one just uses AddRelativeTorque. It seems that after adding relative torque on X and Y, I start getting angularVelocity on Z. Any idea why? Is it because of the format of the Rigidbody colliders?

polar leaf
unique cave
haughty scaffold
pseudo mantle
#

Good day all. I am attemping to make some gold chain necklaces for an avatar. These need to be physics driven due to dynamic choices of animation that can be played/mixed. So far I am unable to get a necklace of any kind to physically interact with the character let alone a working solution. Could someone offer a tutorial link or any advice on how best to get started with this task? I would be most grateful!

maiden quiver
#

Hello everyone, I have a problem and I need help, when I shoot an arrow onto a box the box keeps moving with arrow

potent notch
# maiden quiver

please just google for a second on how to screenshot for whatever os you are using

#

personally i do a mix of both, but usually i try to get the physics non baked if possible, but im not really a normal person lol

polar leaf
# ruby moth

Just want to say that it looks super cool like that 😂

elder ore
#

How come adjusting the center of mass to the bottom of an object on a rigidbody does not have it straighten out when it is falling down?

ruby moth
rotund lagoon
#

I have a character controller with Slope Limit and Step Offset to 0, but yet the character is still walking up slopes and stepping on stuff? Any ideas?

unique cave
#

Why not rig for cloths?

#

Whats wrong with that?

#

Id not make any actual cloth physics, just rig the model so you could easily move parts of the model at once. Using some springs joints and stuff you could connect the rig so it would react to the player movement correctly

worthy glacier
#

i dont set it to 0 but i change it

#
    void Update()
    {
        grounded = IsGrounded();
        if (jumpyCooldown > 0 && grounded) jumpyCooldown -= Time.deltaTime;
        else if (grounded) { canJump = true; canDoubleJump = true; }
        horizontal = Input.GetAxisRaw("Horizontal");

        if (Input.GetButton("Jump") && grounded)
        {
            CoolDownFunction();
            if (canJump) rb.velocity = new Vector2(rb.velocity.x, jumpingPower);
        }
        else if (Input.GetButtonDown("Jump") && !grounded)
        {
            if (canDoubleJump) { rb.velocity = new Vector2(rb.velocity.x, doubleJumpingPower); canDoubleJump = false; }

        }

        if (Input.GetButtonUp("Jump") && rb.velocity.y > 0f)
        {
            rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f);
        }

        Flip();
    }

    private void FixedUpdate()
    {
        rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
    }```
scenic violet
#

Everyone ignored you lol

worthy glacier
#

yea :/

silent path
#

How do I make a cable

timid dove
#

Use a plugin like Obi Rope or build it from connected bodies and hinge joints

supple sparrow
visual star
#

Does scale matter? i.e do objects behave better or worse if they're 25 vs 0.025 or is it all the same to the engine?

worthy glacier
#

it didnt work

supple sparrow
#

Strange, it's still as start awake in the inspector during playmode

timid dove
sudden hinge
#

Hello, i've a problem, for my VR project i needed to multiply the scale by 10 all the gameObject, but my hands are going through the wall and object, do you have any idea ? I don't have this problem at scale 1..

unique cave
timid dove
sudden hinge
timid dove
#

scale is not the only factor here - the original size of the obejct matters too

#

and the "actual" size you want it to be

weary thicket
#

@timid dove I work with @sudden hinge on this project which involves coins colliding together, and the thing is that we found out that the collisions between this coins works better when the coins are bigger. So we tried to make the whole project in scale 10 but it leeds to other problems, like the hands going through objects when it is ok in scale 1.

timid dove
# weary thicket <@179367739574583296> I work with <@238690132562149377> on this project which in...
  • hands going through objects has nothing to do with scale. Make sure your colliders are correct and that everything is actually set up properly for collisions, like moving objects via the physics engine rather than the transforms and the appropriate Rigidbody settings etc.
  • If you want accurate collisions for small objects you'll need to probably tweak some of the physics settings and also probably reduce the default physics timestep from 0.02 to something smaller. Additionally check the same things about how objects are moving
weary thicket
#
  • actually, scale seems to matter because if we do the project at scale 1, the hands does not go through walls! (but the coins interacts weyrdly and the framerate drops dramatically). Couldn't the velocity (or force, or ... something else?) change because of the scale?
  • the time step is already changed to 0.014 so no problem on this side
timid dove
weary thicket
#
  1. the colliders seems to be ok, they grow with the scale. The movement of the hands should be the problem, but we can not find where to change that.
  2. we already tried to change other physics settings with no good results
timid dove
weary thicket
#

We use auto hand. What do you mean in your sentence "You'd need to create proxy objects that do move via physics if you want them to have physical interactions"? (sorry, unity beginner here)

timid dove
#

If you use auto hand seems like something you could/should bring up with autohand

weary thicket
#

Already asked but nobody seems to know! And autohand works with XR, so it might finally be a unity matter

timid helm
#

This is an incredibly simple question so I don't know if it even counts as "physics" but:

#

Should my mesh colliders be boxes or planes?
In the picture the white colliders are currently boxes

#

but should I remove the back ends to them?
Those pink tiles are supposed to be barrier tiles, so you only encounter them in one direction

#

Or should I do this instead?
I'm mostly curious what's best practice. Most efficient.

visual star
#

I was just curious if it matters for the game's performance

#

the ball (equivalent) have a radius of about 0.5 units

unique cave
#

I highly doubt it has anything to do with performance, just try it with real world sizing and see how it works, most likely real world sizes gives most realistic results

visual star
#

if having the radius be 5, or 50, would be better, I'd change it sooner rather than later 😄

#

alright cheers

timid helm
unique cave
timid helm
#

I know it's a silly example, but scaling a mob in Minecraft would cause extreme lag, and I'm assuming it's because the engine itself handled mesh sizes strangely

#

but I haven't seen it matter in Unity myself

unique cave
#

Thats not unexpected but if you scale the whole world, it shouldnt matter. (Also minecraft uses some voxel based physics for mobs so its not at all the same)

visual star
#

okay that's interesting, worth looking into (and I will)

#

thx

timid helm
#

(Also minecraft uses some voxel based physics for mobs so its not at all the same)
righto, thanks for the clarification

stuck bay
#

is there anything like PhysicsScene.Simulate that simulates animations?

#

or simply simulates Update() calls?

pastel meadow
stuck bay
polar leaf
#

Hi , anyone with experience in PID controllers? How do you usually go about tuning them? I'm currently using to manage my AI aim to avoid overshoot and I tuned mine my running a training trough a genetic algorithm. It now works perfectly but my issue is as soon as I change some parameters on the AI forces, my tuning goes down the drain

#

Different AIs have different parameters and also while creating new AIs I will be tweaking the parameters a lot and having to run this genetic algorithm trainings is a bit of a pain in the ass

#

I'm considering if I should use a Neural Network for this. But if anyone has any tips on how to tweak them I would be glad 🙂

strange lark
#

I'm working on a simple character controller, but something I'm not sure on how to handle is after colliding with a wall, I set the actor to the fraction of the vector where the collision occurred (at the position of the wall). However, in the next frame the actor is then "stuck", because the collider cast in the opposite direction seems to hit the wall the actor is next to. I'm not sure what the best way to handle this is

polar leaf
strange lark
#

A custom character controller using the DOTS physics

polar leaf
#

but what are you leveraging? does it have a rigidbody? is it kinematic?

strange lark
#

No physics at all, just collider casts and modifying translation

polar leaf
#

Got it. It's a bit strange because casts usually don't collide with objects they are already colliding at the origin of the cast

#

I would try to add a small buffer so you don't leave the collider exactly close to wall but a lil bit far from it. Otherwise, drawing some debug meshes can help what's going on

strange lark
#

That's what's confusing me, tbh it doesn't even look like the collider is touching the object, but that's hard to tell since the dots visualization isn't great

#

The circle is the character controller collider (a sphere) and the box on the left is the terrain collider

polar leaf
#

have you tried adding a buffer to see if that helps?

#

I have a question on torque application. I'm applying a torque of 42k (Y axis) to a rigidbody with 2500 of mass. According to the AddTorque documentation:

ForceMode.Force: Interprets the input as torque (measured in Newton-metres), and changes the angular velocity by the value of torque * DT / mass. The effect depends on the simulation step length and the mass of the body.)

#

I should be getting 16.8rads/s of angular acceleration. However, I'm only getting 0.98. Any idea why?

strange lark
polar leaf
#

I mean like, imagine you collided at 0.8of distance, instead of advancing the collider 0.8, you just advance 0.6

timid dove
#

Not sure why the docs would say mass

#

Anyway I'd you want a specific angular acceleration just use ForceMode.Acceleration and you don't need to do the math.

polar leaf
#

I replaced by inertia sensor and it works 👍

#

Reported it to unity

#

(The documentation error). Seems they copied it from addforce

mossy iron
#

One way I can think of is to disable the spawned box, do some math to calculate a better spawn location, move the box there, and re-enable it. But I am having trouble with implementation (specifically with finding a better spawn location). The other way I can think of is to apply an opposite force (opposite to the impulse force, that is) to make the box "jump" way less high.

#

Is there a simpler approach that I am missing?

bleak umbra
unique cave
#

Spawning objects on top of each other is not good idea in PhysX, engines like Havok resolves the collisions differently but PhysX uses high forces to try to get out of the situation where colliders overlap, spawning the objects so they dont overlap is the best idea as Annikki said

crude grotto
#

Sorry if this is not the correct channel, but I cannot find any other better fitting one. I have a spider model that consists of several parts. Each leg is a part. Each legs bone has a collider and a script set. That script takes the actual object with the mesh (and rigidbody) as a parameter and will apply force to it on a raycast hit. Unfortunately that has no effect at all (but the code is executed). I tried to detach the object (with the leg mesh and rigidbody) from its parent already as I was thinking that might hold it in place. It doesn't change anything though. That being said, the meshes of the parts don't even move with their transform - not even in the scene editor. They just stay in place with the rest of the spiders mesh. I thought disabling the bone might help, but with no success. Does anyone know what I'm doing wrong here?

#

I also tried destroying CharacterJoint and ConfigurableJoint on start with no success

fluid galleon
#

Hello! I've a question about RigidBody2D::MovePosition() method ; physics generally break even when I do a simple rigidBody.MovePosition(this.transform.position) in OnFixedUpdate handler. As soon as I do it, stuff colliding with my spaceship stop making knockback effects, etc. When I comment out this, physics interactions between objects start to work again. MovePosition cannot be used in conjunction with standard physics?

The thing I want to achieve is to control my entity using purely arcade way but still retain proper physics like knockback when something collides into it, etc. So my idea is to handcraft movement using "fake velocity" and use that with MovePosition to control character.

unique cave
fluid galleon
#

It looks like MovePosition resets velocity to 0/0/0 when called.

unique cave
fluid galleon
unique cave
# fluid galleon Here you are <@689758471003963472>

Ah so the ship is the one thats kept in place using MovePosition. Because its dynamic, its quite expected that it tries to interact with physics but setting the position using MovePosition tries to counter that behaviour

#

Id try to use .velocity for better results

#

Or AddForce for even more realistic movement

fluid galleon
#

The idea behind that is that I wanted to mix player control code with standard RigidBody2D dynamic physics. I wanted to make arcade physics as additional layer on top of standard physics, with simple controls (like pressing left = instant full velocity on the left) and I wanted to combine it with standard physics by calling RigidBody.MovePosition(transform.position + arcadeVelocity);

This way I could have my "arcade velocity" separate from "physics veloctiy" as I wanted to gradually reduce player control when "physics velocity" was > 0, so player control strength would be reduced upon impacts or basically any physics imposed force.

Looks like I'm out of luck here and I'll go with AddForce approach instead. Thank you for your time 🙂

#

I'll probably just go with solution that is commonly suggested over the internet, that is disabling player input for a half second or so to make sure player won't be able to nullify impacts by inputs. 🙂

rotund lagoon
#

When using Physics.CapsuleCast will the Hit.point be the center of the capsule when it hit or the point on the edge of the capsule where it hit?

timid dove
#

if you want the center of the capsule when the hit happened you'd do:

Vector3 centerAtStart = Vector3.Lerp(point1, point2, 0.5f);
Vector3 centerAtEnd = centerAtStart + direction.normalized * hit.distance;```
carmine basin
#

thinking of adapting a current shooter project thing i have in unity so it works in VR
it uses some maths™️ to simulate real bullets, but hitscan style
so the only part of the bullet that actually "exists" is a tracer kinda thing; a trail renderer
I was thinking of making the arms physically simulated and doing the recoil via rigidbody forces,

Has anyone tried ragdolls with guns before?

carmine basin
#

Im getting a really, really weird thing with configurable joints. I have two arms, set up identically. And they're both behaving differently

#

Its not being animated or anything

#

Its rotation is just completely locked?

potent notch
#

im wondering if the source code for add force is known? I'm trying to recreate it for nvidia flex

bleak umbra
potent notch
bleak umbra
potent notch
#

lol, maths and physics is not my forte lol, but thanks so much for this all!

bleak umbra
potent notch
bleak umbra
#

alt least you have dreams

#

That’s important too

potent notch
#

yas, and a whole lot of persistance, i once was planning to go through every single int until i found the right version number for something, then i realised it was written on the github read me....

bleak umbra
#

I guess games are dreams cast in math

potent notch
#

lol

bleak umbra
potent notch
#

lol, i could never do the 3d modelling stuff though lol

#

i remember after 2 years of attempting to learn blender i showed someone an attempt at making a dragon, their first reaction was "oh goodness is that a snail with wings?"

bleak umbra
#

😜

potent notch
#

lol

bleak umbra
#

modeling is easy. Sculpture is hard.

potent notch
#

both are a nightmare for me lol

slender bone
#

Does anyone know why my mesh collider isn't working?

timid dove
slender bone
#

White (player) falls through green (ground)

timid dove
slender bone
#

wasd

#

but it falls vertically through gravity

sweet wave
#

People must ask this all the time, but is there a reason why my player car is stuttering and jiggling? the code for it is very simple, just a transform vector 3 forward. one line of code. let me film it hold on

#

Im following a unity learn tutorial and it looks just like his, afaik, but his is smooth

shell ginkgo
#

Hey, anyone know if there's a "proper" way to shoot a raycast out of a character with multiple colliders? I set up my character using the ragdoll wizard, thinking that each limb would be considered part of a compound collider, however that doesn't seem to be the case. Shots hit colliders on the way out of the player.

I could use a layer mask, but each character would need its own layer in order to shoot eachother and that seems inefficient.

I've also seen people suggest using RaycastAll, but I'd imagine multiple characters shooting eachother would lead to the game bogging down.

dawn plank
#

or you could offset the beginning point of the raycast in direction of the raycast so that its outside of your own colliders range

shell ginkgo
#

Well what would the process for layer management be for multiple characters? If I didn't care about friendly fire, I could have each "Team" on its own layer, but I do want allied characters to be able to hurt eachother.

As for offsetting the raycast origin - I was originally going to have a "realistic" shooting system where shots properly originated from the barrel of your gun. Even had a system to move it out of the way when you got too close to a wall. However, once I layered animations ontop of it it just felt bad, so I reverted to the simpler style of shooting from the player's camera

#

I could probably get away with having the offset for NPC characters, since navmeshagents won't get too close to walls, but there's always the risk of shooting through objects with an exterior raycast origin.

Raycasts from within a single collider exit without issue by design: Notes: Raycasts will not detect Colliders for which the Raycast origin is inside the Collider. so if that origin goes through a wall, the character can shoot through that wall.

#

I actually was counting on this, anticipating that multiple colliders on the same character would get treated as a compound collider as mentioned, but that's not the case apparently.

potent notch
#

wondering if anyone else using nvidia flex has noticed crashes happen randomly? I literally will create a new scene, and copy every object from another scene into the new one and it will crash on load despite it being essentially the same as the 1st scene, weird

potent notch
fluid lagoon
#

hey,

is it possible to render Plane on both sides ?

carmine basin
#

yes, create a material that renders on both sides, assign it to the plane

#

this is hardly physics related tho

fluid lagoon
carmine basin
#

no

carmine basin
#

Mesh materials do not affect physics at all

fluid lagoon
carmine basin
#

Either way

#

materials do not affect the collisions

fluid lagoon
#

ok, so I will try the invisable side again, if it didnt work, I guess I will have to either use a box in stead or a another 1 side plane, right ?

carmine basin
#

probably

shell ginkgo
#

Turns out there was a sweet spot I could place it in to avoid that issue, and the issue of having the shot source be outside of the player

dreamy quail
#

I have some vr hands

But they go through objects

How can I make a rigidboy that tries to match a coordinate but stops when hitting something

potent notch
full rampart
#

Hi i have a little problem

#

Why is my player falling this slowly ?

carmine basin
white spire
#

Im using a boxcollider 2d to collide with compositecollider2d s but the colllision isnt getting detected, not even in the "contacts" tab under the colliders
this is unusual considering how it worked nice the other day and suddenly stopped working

#

after i switched a few things around

#

what could be going wrong?

#

not exactly physics as both are triggers but i found this to be the closest channel

fluid lagoon
#

Hi,
I know mesh collider is expensive, but if I have 10-100 mesh colliders on cubes and spheres with all those objects are set to be "Static" ... would that help with the fps dropping by them ?

unique cave
# fluid lagoon Hi, I know mesh collider is expensive, but if I have 10-100 mesh colliders on c...
  1. Marking objects as static doesnt help afaik, same AABB tree is used for both dynamic and static objects
  2. Mesh colliders arent automatically expensive, all collision checks goes through the broad phase check meaning for most objects the actual shape of the collider doesnt matter. So the actual physics overhead is mostly defined by the amount of narrow phase checks and their collider types (https://developer.nvidia.com/gpugems/gpugems3/part-v-physics-simulation/chapter-32-broad-phase-collision-detection-cuda#:~:text=In the broad phase%2C collision,set of pairs of objects.)
  3. Why mesh colliders for cubes and spheres? Why not using BoxCollider and SphereCollider?
fluid lagoon
#

@unique cave thank you for 1 and 2 , they really clear things out.
3 - I'm working on a painting game/app , i need the TextureCoord which is only available with mesh colliders( or at least its way easier to obtain with mesh collider)

crude grotto
#

I have an animals tail with around 20 bones. I tried both the Character and ConfigurableJoint to get Ragdoll effects on it. My problem is, that any colliders on the bones will make the physics jitter the tail massively. I have tried setting IgnoreCollision and re-enable the Colliders at Start(). Nothing works. Can anyone help me? 😦

#

Without the colliders the physics work fine

charred slate
#

I have an issue where it seems gravity on units are going faster after I exit and return to play mode the first time. This issue doesn't resolve until I restart the editor. This is Unity version 2021.3.9f1 URP.

Any ideas?

charred slate
crude grotto
carmine basin
# crude grotto

That's a lot of joints. Do you have "Enable Collision" turned on in the joint settings?

crude grotto
#

No, its disabled

carmine basin
#

Another solution could be creating a layer for all the joints there, and making that layer not collide with itself

crude grotto
carmine basin
#

That's fair enough. Hope it goes well

crude grotto
carmine basin
#

Weird

#

I honestly don't know what it could be

charred slate
#

@crude grotto expand that capsule collider component it looks like you have a massive one in place.

crude grotto
#

I just removed a couple of joints for testing, so please ignore that 🙂

#

Maybe I can move the colliders into a new Gameobject each and move these into a different non-colliding layer as the joints?

#

I did try moving them into a layer that does not collide with itself already tho as LunarEclipse suggested

#

(I moved the Gameobjects as they are now altogether into the layer, not just the colliders in separate Gameobjects)

charred slate
#

Can you show the full information of that capsule collider?

#

Like this? @crude grotto

crude grotto
#

Theyre all like this one

timid dove
crude grotto
#

I guess because the prefab it resides inside is based on a model that is converted "1cm (File) to 0.01m (Unity)". If I create a sphere with the same measurements outside of that prefab, it's a different size than inside of it. Outside its so small its not even visible

#

*capsule not sphere

#

Also the Armature has a scaling of 100x100x100

#

(Which is the root element of those elements with the colliders)

crude grotto
#

After 2 days of rage and despair it turned out that my issue is related to the collider size. If I increase it - even to a point where they keep hitting each other - this buggy behavior is gone. If I then move it into a non-colliding layer its super smooth. Thanks for the help everyone

#

I wish I knew exactly whats happening so that I don't have to empirically find a working size, but at least I'm a step further

stuck bay
#

How create a phusic Drag mouse?

charred slate
charred slate
potent notch
crude grotto
white spire
charred slate
potent notch
charred slate
#

Let me test it now.

charred slate
potent notch
charred slate
#

Worse. lol

potent notch
#

see how far you can push it, what is the limit of how worse it can get, i do admit that this probably wont help us fix the issue, but it could be fun

charred slate
#

Odd thing, whenever I reload script assemblies(save a script) the issues resolves itself temporarily.

potent notch
#

weird

charred slate
#

Yeah 3rd time around and 4th are getting progressively faster where 4th is about the max speed I'll get.

potent notch
#

that is indeed odd, is it the physic frames that are getting faster perhaps?

#

use a stop watch in your code that prints what time it is at every time a fixed update occurs

#

then compare the first playmode and the 2nd time

charred slate
#

Looks like I got it.

potent notch
#

ooh congratz

charred slate
#

If I got into editor settings and enter playmode settings to reload on scene and build. It resolves the issue.

potent notch
#

ooh good job!!

charred slate
#

The questioning helped. Thank you!

potent notch
#

no problem, have fun!

crude grotto
#

Now that the joints on the tail are pretty stable, the leg ones are still going wild and I am out of ideas so I'd like to ask a last time for any ideas before I give up.
I tried all kinds of configurations on the joints and colliders during the last 10 hours. I just can't get them to be stable.
I can reproduce it by creating tiny capsules. At a specific size they just start doing this. I cannot really do anything about that in my model though. Its the actual size ingame with the necessary joints.
As you can see in the video, the joints work okay until I disable kinematic. Workarounds would be appreciated as well 🙂

jovial wraith
# crude grotto Now that the joints on the tail are pretty stable, the leg ones are still going ...

this looks like physics solver instability. Increasing the physics solver iterations should help reduce the jitter and prevent the wild freakouts. But looking back at your previous posts, I think the tiny collider size w/ massive mesh scaling is making the problem worse. You're essentially scaling it down w/ tiny values and scaling it back up with large scale factors. I suspect the floating point inaccuracies and other rounding errors that introduces is making your physics simulation less stable, though I can't say for sure. If you can scale your model outside of unity so you don't have to import it in a way that requires 100x scale factor I think you'll have an easier time.

#

https://docs.unity3d.com/Manual/class-PhysicsManager.html

Default Solver Iterations Define how many solver processes Unity runs on every physics frame. Solvers are small physics engine tasks which determine a number of physics interactions, such as the movements of joints or managing contact between overlapping Rigidbody components.
This affects the quality of the solver output and it’s advisable to change the property in case non-default Time.fixedDeltaTime is used, or the configuration is extra demanding. Typically, it’s used to reduce the jitter resulting from joints or contacts.
Default Solver Velocity Iterations Set how many velocity processes a solver performs in each physics frame. The more processes the solver performs, the higher the accuracy of the resulting exit velocity after a Rigidbody bounce. If you experience problems with jointed Rigidbody components or Ragdolls moving too much after collisions, try increasing this value.

crude grotto
#

Thank you! I’ll look into that. I didn’t create that model myself so I hadn’t questioned it too much - as I’m new to the whole topic. It sure seems strange that my armature has a 100x100x100 scale forcing me to go for such tiny values on the bone colliders

crude grotto
oak topaz
#

top 8 physics tools on the store right now. do you have any of these?

crude grotto
white spire
#

Im using a boxcollider 2d to collide with compositecollider2d s but the colllision isnt getting detected, not even in the "contacts" tab under the colliders
this is unusual considering how it worked nice the other day and suddenly stopped working
after i switched a few things around
what could be going wrong?
not exactly physics as both are triggers but i found this to be the closest channel

oak topaz
timid dove
white spire
#

oh really thx

#

i actually just resolved the problem and it seems like a tag error

dusky eagle
#

Hi, everyone. I have a game that is built around physics interactions, and I'd like to add multiplayer. As far as I can tell, Unity Physics by default use PhysX which are non-deterministic. Is this correct?
Should I look into switching to havoc before trying to implement multiplayer/client syncing?

trail palm
#

how do i make my ragdoll not fall down and stay on its feet ?

carmine basin
copper inlet
#

If you're looking to run a lot of physics objects at a high fps, use the Unity Physics in the DOTS package. You can run up to 1m physics objects in realtime depending on your PC. It's awesome. With the only downside being that you need to use ECS, of course.

dusky eagle
#

I didn't even know enhanced determinism was a thing. That's so simple, thanks!
I have only a few dozen active rigidbodies at any time so I'll try just enabling enhanced determinism.
I'll keep DOTS in mind for future projects, thanks!

fading hatch
#

Hello, I have noticed in my game that the movement on a better computer is slightly faster and better than on a phone. The problem is that I don’t want this because it’s a mobile speedrun game

#

How can I prevent this from happening

timid dove
#

you need to make it framerate independent

fading hatch
timid dove
#

This means either:

  • Using Time.deltaTime to adjust things
  • Using FixedUpdate for movement
timid dove
fading hatch
timid dove
#

Doubt it 😛

#

anyway I've seen it all

fading hatch
timid dove
fading hatch
#

@timid dove do u have a solution yet?

timid dove
#

don't see anything in the Player script that is framerate dependent

fading hatch
fading hatch
timid dove
#

nothing in here is framerate dependent either

#

although

#

maybe this timer script?

#

What is Stopwatch?

fading hatch
#

k let me send it to u

#

yeah

timid dove
#

not really seeing anything there either

#

can you explain or show exactly what you're seeing that's a problem?

#

Character is moving or jumping faster or something?

#

maybe it's just looking smoother and that's confusing?

fading hatch
#

No, it’s like rotating a little bit faster

#

And the movement also lags way more on mobile then on pc

#

@timid dove

timid dove
#

wdym by "lag"?

fading hatch
#

k

crude acorn
#

Any tips on getting AI to plan around other characters going in and out of range due to their animations?

#

And also handling collision with "flexible" colliders, like the crocodile's tail. Current plan is to set those to work as triggers only unless intentionally being used by an animation to apply physics

#

Does swapping a collider back and forth between trigger and not affect the rigidbody center of mass?

unique cave
jovial wraith
gritty socket
#

so do anyone use the unity xr interaction toolkit? has anyone experience slow rotation on setting grabbable objects to velocity tracking?

#

not necessarily about lagging a frame or 2 behind the actual hands, but more of the rotations are really slow

balmy raven
#

How to set local variable in VSC?

timid dove
old garden
#

Hello, I hope everyone is doing good ||and I am asking the question under the right channel||

#

I want to move a tank; and have basic but realistic physics interaction of the track-drive wheel and the ground

#

My question is; how would I achieve this?
What might be my options?
(And I am completely new to unity and game development in general. You can just point me to what I should be looking for to learn and implement, to achieve what I want to do)

old garden
#

and me messing about stuff by looking up youtube videos

old garden
# old garden

The interaction of drive wheel with track I have as secondary. Mainly track with ground is what I am looking for (but I do believe if I manage that then the track to drive wheel interaction would be pretty much the same thing, if not easier)

timid dove
old garden
timid fulcrum
#

hey im making a center of mass to my car and i added to it but when i click play my car bounce to the sky

#

i dont know why

stuck bay
#

May I have help to make plane physics?

unique cave
rotund lagoon
#

Can I CapsuleCast with a zero distance? If I want to check for collision before I change transform to that position? (So i dont want to check for a clear path from A to B, i just want to make sure that B is clear)

copper inlet
#

Nvidia omniverse might actually be coming to Unity pretty soon! Really hope that's the case, I'd love to fuck around with an actual newer version of Flex

timid dove
potent notch
copper inlet
#

Tbh, I shouldn't be that excited, I can barely run 1.2.0 at 10 fps lmfao

timid fulcrum
#

someone know why my car do that?

#

i was trying to rotate the wheels when the car is moving

#

i dont know why i did wrong

timid dove
#

you should be looking at the gizmos and tool handles etc to see the actual positions of objects and colliders etc..

fleet stone
#

@timid fulcrum I’d create an empty parent and put it in the middle of the wheel, re attach the script and try again

timid fulcrum
#

i will try that thanks

fleet stone
#

I haven’t even thought about rotating my wheels in my game because it’s very low poly, but if I were to do it I’d animate the wheel rotation and then in the script have it play the rotating wheel animation when I’m using the forward input key (probably w for you?)

timid fulcrum
#

is a good option

#

yes the w

timid dove
#

you shouldn't be physically rotating any physics objects

#

you should use WheelCollider

fleet stone
#

Yes that too

timid dove
#

and just use the GetPose stuff from it to rotate and position your wheel which is purely a visual element

timid fulcrum
#

i use wheel collider

#

getpose i never listen that

timid dove
#

which object(s) have which component(s)

#

etc..

timid fulcrum
#

yes sure

#

wait

#

in FL i have the collider

#

and in Wheel LF i have the visual wheel

#

in all the wheels is how that

#

if you need something to see tell me

timid dove
timid fulcrum
#

ok

#

here are

timid dove
#

that's the same image as before

timid fulcrum
#

the green is the collider and the blue is the visual wheel

timid fulcrum
timid dove
#

show with the visual one selected

timid fulcrum
timid dove
timid fulcrum
#

no

timid dove
#

is this like a skinned mesh renderer?

#

Notice how your visual wheel's pivot is in the center of the car?

fleet stone
#

Also the move crosshairs is in the middle of the car

#

Yeah

timid dove
#

If this is a single rigged mesh, you're going to have to go fix that in Blender

timid fulcrum
timid dove
#

you have to fix that in Blender or whatever 3D modelling software

fleet stone
timid dove
fleet stone
#

How come?

timid fulcrum
#

but i dont know how use blender

#

what i should do in blender

timid dove
timid dove
#

they can't introduce new bones

#

it will break the animation

#

well it's already broken to be fair...

timid fulcrum
#

but idk why this isnt working i am seeing a tutorial and is the same

fleet stone
#

Yeah, if he knows how he could re make it, I just had to do it last night with a door

fleet stone
timid fulcrum
#

no

fleet stone
#

Do you have pro builder?

timid fulcrum
#

i installed on a page

#

because i didnt like the model of the tutorial

fleet stone
#

Just make new wheels with pro builder haha, that’s what I’d do atleast

timid fulcrum
#

design wheels?

timid fulcrum
fleet stone
#

Actually that won’t work either because those wheels are pretty round and I don’t think pro builder has cylinders that high poly count

timid dove
#

just go into blender

#

cut the wheels out

#

it's not that hard

fleet stone
#

What I’d do, if you really want to make this work, I’d learn learn blender

timid fulcrum
timid dove
#

just select all the vertices for the wheels and there's a way to separate the mesh

#

you can make it a separate object

#

and your life will become easier

timid fulcrum
#

wait me

timid dove
timid fulcrum
#

it should intall it fast

fleet stone
#

I believe in u 🫡

timid fulcrum
#

thanks

#

then it is problem of the model and no of the script

#

?

#

2 minutes and i have blender

#

i have it

#

i cant put the car on blender

#

😫

timid fulcrum
fleet stone
#

What’s the models file type? Sorry I was driving

#

Once u know the file type then in blender hit file, import, choose the same file type as the car model, and then u should be able to find it in your file explorer

sacred vault
#

hi, guys, I have an issue with box collision and collision overall.
I have high velocity missile that come from the sky, and when it reach the ground, it explode.
My current issue is that the particle system is spawning inside the ground

#

there is no offset what so ever on the particle system.