#⚛️┃physics

1 messages · Page 12 of 1

coral mango
#

That is what I'd expected but I'm not at a computer to test so I didn't wanna say for sure

timid dove
#

PhysicMaterials

viral beacon
#

What? Physic materials dont have anything like that.

devout token
#

Not by default, no
Speaking of, @subtle sequoia how did your quest for squishy colliders go?

shut root
#

My player keeps falling through the floor! Here's what's on the Player gameobject (image1) and here's what's on the floor (image2)

subtle sequoia
devout token
#

oof UnityChanBugged

viral beacon
#

I wish there was just a way to take a fraction of collision forces.

subtle sequoia
#

to get it to work I had to basically reimplement the contact forces by hand in C# land and that brings in all the joys of mono performance being a nightmare.

devout token
#

I guess the only remaining option would be some very generalized repelling force based on distance to an arbitrary point

#

But obviously it can't practically be very accurate

subtle sequoia
#

I tried putting limiters on the contact force too but yeah we just don't have enough control in the callback

#

physx doesn't seem to support too much more than what unity does but there are a few misc settings that would help

devout token
#

Maybe sampling an SDF for the repelling point's location could be used to some interesting effect

viral beacon
#

if only there was a way to intercept the application of collision forces

subtle sequoia
#

I mean, there is always a way just a question of if it involves writing shellcode or not

devout token
#

Something that'd be easy working from the inside out but really not worth it for us

subtle sequoia
#

In my case I needed it to get halfway decent stair handling on a character controller

#

instead I no longer have stairs XD

devout token
subtle sequoia
#

Controller does all surface handling and whatnot by hand through forces and relies on the physics engine purely for feeding in contact info and keeping things from clipping into eachother

#

the soft was just a way to make it so geometry of colliders wouldn't get caught on eachother

#

since I'm handling that seperately

narrow harbor
#

Hi! Between 2 colliding objects, I want one to bounce, other to go through. How do I accomplish this?

#

For example, I have a wall, a red wall and a blue wall. I want the blue wall to bounce off the wall. But I want the red ball to go through the wall.

#

Both balls must act similarly with other objects, like normal bouncing balls.

#

So what do I have to add to the wall's colliders to let the red ball through and not the blue wall.

#

Assume that blue and red balls are separate prefabs.

#

i can't use layers, because the blue and red balls both have the same layer.

timid dove
#

IDK why you are precluding that. It is by far the best/simplest approach

narrow harbor
#

Due to some restrictions, I cannot keep the layers of the balls different.

timid dove
#

for example the colliders do not have to be on the same GameObject as whatever other thing you need to be on whatever other layer

#

the colliders can live on child objects

narrow harbor
#

The restriction is not from Unity. The restriction is that I can't make more layers. I can have a Ball layer. But I can't have a BlueBall Layer and a RedBall Layer

timid dove
#

If it's not a unity restriction I don't understand what you mean.
I guess it's a homework assignment or something?

narrow harbor
#

Not a home work. But a task from someone to get it done without making more layers.

#

Because we don't have space for more layers.

timid dove
#

so reuse some existing layers

narrow harbor
#

Hmm. I'll try to brainstorm how I can get that done, by using some old layers without affecting anything else. It's a big project, you can say with loads of other things happening in the same scene.

#

Thanks nonetheless

#

Just to be sure, is there any other way of using colliders or rigid bodies to get the work done?

timid dove
narrow harbor
#

Yeah. I guess so xD

timid dove
#

but you have to call it for every specific collider pair that you want to ignore

#

if you only have a few walls and a few balls it might be not that terrible?

narrow harbor
#

The balls will be generated on run time. Can be 100+. The walls will be there already.

carmine basin
#

I have a... somewhat complex problem.

#

I'm hoping to achieve movement similar to Titanfall; incorporating sliding and wall-running.

#

However, I also want the player to be able to be affected by things such as explosions and to naturally slide down slopes that are too steep. I've tried with a CharacterController but the results for anything fall-related were... Jittery at best

#

That's only context, not something that I want answering

#

The issue is this -
I want to modify the velocity to have an "additive" velocity that will be used to move the player laterally, while keeping the velocity along the y axis largely unchanged, except for when I need to change it.

#

I'm considering adding forces to provide the movement, and then changing the properties of the phsyic material on the player to facilitate things such as sliding and wall-running

narrow harbor
#

Only 3

timid dove
# narrow harbor Only 3

then whenever you spawn a ball you can call IgnoreCollision between it and each of the 3 wall colliders

narrow harbor
#

Btw, there's an Exclude and include layers option in Collider components

#

In the inspector

#

Do they perform the same thing?

timid dove
#

oh right

#

i forgot about those

#

they are new

#

There's something similar for the rigidbody too

#

you may be able to use those

#

I always forget about those since they're new since around 2022 I think

timid dove
narrow harbor
#

I see. I'll test them out. I appreciate all the help!

void grotto
#

I am looking for an incredibly comprehensive overview on physics components like Physics Materials and Constraints and how they affect forces and interactions. I want to try to un-black-box the underlying physics engine, but most of the stuff I can find is surface level information or "here's what this value is, fiddle with it till it looks right". I have at least a cursory knowledge of newtonian physics from college, so I'm not afraid of math. I just want to know what, exactly, is happening in different situations. I expect something like this would be a video just to show what happens, but text is fine. Anyone have any recommendations?

zenith stratus
#

Hello, English is not my mother tongue, so I can make a lot of mistakes. I have a problem, my player can’t move and I don’t know why. I made an animation and I stop the movement of the player to change scene, and after that my player can no longer move. So I just put this change in comment, but it doesn’t change anything.

devout token
#

But that's only a guess, we don't have a lot of information about how you are "stopping" the movement or what the animation does

zenith stratus
#

Oh ok, i don't know that, thank for your answer.

acoustic oriole
#

So I am trying to replicate the spring system of a car and wrote this code. According the code, the car should keep bounce up and down where the highest point it will reach is exactly the same as the starting point. It does so for some time but then it start to go all weird. Is it because of the framerate inconsistency? What exactly is causing this?

private void FixedUpdate()
{
    foreach (Transform wheel in wheels)
    {
        RaycastHit wheelHit;

        if (Physics.Raycast(wheel.position, Vector2.down, out wheelHit, wheelSize, groundLayer))
        {
            float springCompression = wheelSize - wheelHit.distance;
            float springForce = springConstant * springCompression;

            _rb.AddForceAtPosition(wheel.up * springForce * Time.fixedDeltaTime, wheel.position);

            Debug.DrawLine(wheel.position, wheelHit.point, Color.green);
        }
    }
}
#

Also, the error in movement is always the same. The block always falls in the same manner. If it is because of frame rate inconsistency then how is the it always the same .

timid dove
acoustic oriole
# timid dove I don't see anything in the code that should guarantee the highest point being e...

Its the physics involved that guarantee it. All the potential energy stored in the car ( because of some height h ) will be converted into kinetic energy while falling down. That kinetic energy will be converted into the potential energy of the spring ( due to compression ). As there is no loss of energy, the spring will bounce back and all of its stored potential energy will be converted into kinetic energy that will move the car upwards, and should reach the same height as all the kinetic energy is converted back to potential energy. We can see it in action for the first few bounces. The height remiains the same but suddenly it starts acting weird.

timid dove
#

Unity is not real life

#

it uses a physics simulation which is a nice imitation of real life newtonian physics but is not going to be perfectly accurate

#

Unity uses PhysX which is a physics engine desiged for real time performance at the expense of physical accuracy

acoustic oriole
#

Yeah thats what I was asking. Is it because of the frame rate inconsistency or some other thing. Cz i was told that difference in frame rate might cause this.

timid dove
#

framerate is irrelevant

#

The physics system runs on a fixed timestep

#

it's just due to the inherent inaccuracies of the simulation

acoustic oriole
#

Got It.

#

thanks

timid dove
#

in your case it seems it's hitting the ground and a torque is being applied somehow

acoustic oriole
#

Yeah, and its always the same

#

teh rotations and collisions

#

all exactly the same

#

I mean, floating point inaccuracy can be a thing. As spring constant is large number even small errors in determining the spring distance will lead to abnormal forces which can provide the torque

#

But it happens to the same wheel in that case, by the same amount

timid dove
#

yes because you're running the same simulation every time with the same inputs

#

on the same hardware

#

It's not that the simulation isn't deterministic, but things like floating point inaccuracy means it won't be perfectly accurate to what you'd expect in real life

#

also the fact that it's a fixed timestep sim is different from reality's "continuous" simulation of course

acoustic oriole
#

Makes sense

#

I am gonna add damping to it anyway so it would not be an issue. Just got confused a little what was causing it haha

novel furnace
#

Is there a way to make a rigidbody behave as if it has high inertia but without making it super heavy so it still tumbles and reacts to gravity like a lighter object? As in, to other objects it seems abnormally heavy, but to gravity simulation it has the expected weight.

Trying to make a physically simulated object in VR that isn't heavy but also isn't easy to slap around.

devout token
novel furnace
#

I've tried that already, but it's jointed to another object and the drag makes it act like it's falling through thick liquid

#

I could potentially try to fiddle with the spring/damper values as well as drag though, maybe that'll help

devout token
novel furnace
#

So increasing drag is partially like decreasing mass?

misty cairn
#

just think of drag as air resistance

#

anyway

#

how would i make a fixed joint 2d automatically align with the other object

#

it has an anchor

#

and place that anchor on the other object

#

not picked up

#

picked up

wise portal
#

I'm experimenting with procedural generation techniques and came across this example where rectangles representing rooms are given physics colliders and randomly placed, then the physics engine is run until all the colliders go to 'sleep'.

#

the issue is it takes a while to resolve the collisions even when I adjust Time.fixedDeltaTime

#

I've got the 2D physics settings to "Fixed Update"

#

how would I go about getting that burst effect the first gif has?

devout token
wise portal
#

okay, I'll give that a go. Thanks

wise portal
#

much better

#

adjusting "maxLinearCorrection" allowed the GameObjects to be moved much faster but unless I also adjusted the "baumgarteScale" the colliders would never go to sleep.

devout token
# wise portal

How do you plan to turn these into connected rooms I wonder
Considering they're just loose physical parts at this point

wise portal
#

first I need to figure out what rooms should connect to each other

#

then draw some corridors

timid dove
steel sorrel
#

Anyone knows why Physic interpolation takes sooo much more processing power than just Lerping the transform? I ask cuz to my knowledge Unity uses a simple linear interpolation between 2 fixed updates, no? ... there is even some calculation done on colliders that are dynamic EVEN WHEN THE FIXED UPDATE ISN'T CALLED xD ... there is probably a reason, but i can't think of one atm

coral mango
timid dove
#

It would be pointless if it happened in FixedUpdate

steel sorrel
drifting shale
#

My NPC is submerging into the ground

#

I don't know what to do. Googled it and could not find a solution

steel sorrel
hearty acorn
#

I can screenshot my components for anything if needed

hearty acorn
still sluice
#

ok, ive got a kinda complicated question as ive never used unity physics before. ive got a fence gate as seen in the image below. and i want to anchor the left sie to the fence postr but when the gate itself collides with the player it gets pushed open

#

does it need to be a script top anchor it to the post?

timid dove
viral beacon
#

I notice that articulation bodies seem to have a sort of elastic behaviour when it comes to acceleration. While a rigidbody accelerates rather smoothly, articulation bodies seem to accelerate in jumps. Does anyone know more about this or why it happens? I want to make sure it wont have too much of an impact on the physics equations I made while testing with rigidbodies.

dark bloom
#

physics make me go Y E S

stuck bay
#

Question that makes me feel dumb for asking again: what's the IsKinematic/IsTrigger combination between two pairs that causes a collision event?

forest lance
timid dove
hollow echo
fossil meadow
#

Hi, Configurable joints are a mystery to me. I'm trying to figure out the current position of such a joint inside its configured limits (ideally as a normalized float or an equivalent ranged value); articulation bodies have dedicated methods/properties for this, but the configurable joint does not. How do i calculate it properly?
I'm lost even figuring out the coordinate space each joint part (with connected body assigned) sits in or rather derives it's motion/limit calculations from

tawny citrus
#

Guys My jumping feels weird ngl

#
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public CharacterController controller;

    public float speed = 24f;
    public float gravity = -9.81f;
    public float jumpHeight = 3f;

    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;

    Vector3 velocity;
    bool isGrounded;

    // Update is called once per frame
    void Update()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if(isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);

        if(Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }

        velocity.y += gravity * Time.deltaTime;

        controller.Move(velocity * Time.deltaTime);
    }
}
#

This's the code that I used for my jumping

#

it feels really weird tho

#

It's from brackey's 3D movement tutorial

#

also, my falling is really floaty

#

like I can literally move side to side mid-fall

#

Help would be very much appreciated as I'm trying to move on to the shooting aspect of this passion project however shooting would be very funky with these trash physics (definetly something on my end)

#

If you have help send in my DM'S please

tawny citrus
#

UPDATE: GUYS I FIXED IT

#

so the code is fine (thank god...), I just forgot to go into the player movement component and bump up the gravity and jumpheight

modest agate
#

Hi guys !
I'm trying to make objects flotable on a water area and it works perfectly with Unity base 3D objects like cube and sphere, but when i try to use custom objects whit mesh renderer, i have to passe the mesh into convex otherwise the object wont detect water. But with that my custom object bounce very hard on water and waves, any ideas on why ?

steel sorrel
# modest agate Hi guys ! I'm trying to make objects flotable on a water area and it works perf...

you are probably attempting to simulate it, and thus one of the colliders goes so deep in the water it gets shot upwards, the other collider going down having all the weight and repeat the cycle

a more professional approach would be to +) get position of vertices of mesh, can be transforms if u don't wanna use mesh.API, no shame in that +) predict where the floating shape SHOULD be +) lerp it to that position.

more predictable that way

but, if you are going for a funny/dynamic feel like gang beast or fall guys, then consider raising the Drag and Rotation Drag as a quick fix ... it's water after all

to make interactions responsive you can lower both drag values OnCollisionEnter and lerp it back to its original values over a short time

#

Try and look at other people that try and do that and see how different approaches feel ... choose the one you like the most

... I'm the gamer that goes into the options and disables such feature for that 2 percent FPS increase, so you can gess what road ai'd choose 😊

rocky shore
#

I'm using a first-person camera but as I was building the lake I went to press play and now my character no clips through the terrain, any ideas on how to fix this or reset the camera properties

upper tangle
#

Does anybody have a quick solution to the following?:

I have 2 clickable sprites, one on top of the other. Is there a way to make it so that one ALWAYS takes priority when that area of the screen is pressed?

upper tangle
timid dove
#

How are you detecting the click?

upper tangle
quiet anchor
#

how do i change bounciness and how do i make it so i can drag it

hollow echo
quiet anchor
#

how???

hollow echo
hollow echo
#

Right click in the project view

#

or go Assets/Create

#

it's an asset so you can share it between components

quiet anchor
#

? sorry im new

hollow echo
#

Right click in the project view

quiet anchor
#

im really sorry, where is that?

hollow echo
#

your screenshot

quiet anchor
#

like this?

hollow echo
quiet anchor
#

here?

hollow echo
quiet anchor
#

oh ok

#

sorry

#

thank you

quiet anchor
hollow echo
#

Go to this path, create a Physics Material 2D. I forget if it's at that path for all versions, you can check the Physics Material 2D docs if it's not there

quiet anchor
#

ok tysm

quiet anchor
#

i did this bouce thingy

hollow echo
#

Dragging is harder, there are physics 2d examples pinned to this channel that are a fantastic overview with examples of how to achieve most things, including dragging. If you get stuck looking at them you should find a tutorial on dragging 2D physics objects in Unity

quiet anchor
#

oh ok

#

thank you so much

steep ridge
#

Hi people! Can anybody confirm that is not best practice to use functions like MovePosition, AddForce, etc in trigger callbacks?
By intuition I would say that triggers are processed by physics, but for callbacks like OnTriggerStay2D the description says that it is "Sent each frame where another object is..." so, that is a per frame check, hence not physics "friendly"?

timid dove
#

They are physics friendly

#

On the contrary you shouldn't process input in those callbacks for exactly that reason

steep ridge
#

Thank you!

prisma fossil
#

i need someone to help me . I want my game character to move his head with the camera ... i cant find a good tutorial that would help.

lilac wedge
#

hey guys simple question. in 2D it's very easy to have a trigger collider with arbitrary shape, just use edge colliders and you can achieve pretty much any shape.

But I moved my game to 3D and now I have no idea how to achieve a trigger collider with arbitrary 3D shape. Can you tell me what's the best way to have that? Box collider doesn't cover cases for an L-shaped corridor, etc.

I set up my trigger colliders so that they can fill any room / corridor so that I have a callback whenever the player enters or leaves a room.

timid dove
#

It's basically the 3d equivalent to PolygonCollider

pure oak
#

Hey I have a little issue with a 2D platformer where when I make a moving platform the player does not always move smoothly with it. With a vertical one it send the player up a little above the platform when it reaches the top and starts going down. Also with horizontal ones the player moves with the platform but slides a little when it switches directions. I'm using rigidbody.velocity for player movement and platform movement. The way the platform moves is by setting a counter to count up and down depending on which way the block is moving and it'll flip and start moving the other way once the counter goes up or down. That part works fine but how do I get the player to stop sliding on the platform without using a crazy amount of friction because then the player struggles to move on the platform? Also with the vertical moving block how do I get it to not send the player into a little jump at the top?

tranquil sonnet
#

Hello everybody! I hope I'm posting to the right channel 🙂

I have an issue with character controller + large terrain + UI. Up to this point my character was always near origin, but now that I expanded my terrain considerably (1 single terrain, 8192 x 8192 units, the center of the terrain is around [0, -150, 0]) I noticed that the UI starts jittering the farther you are from the center (it's visible 200 units from origin, around 2000 units it's jumping all over the place).

I tried changing all physics settings. I believe the issue is that even a tiny change in the parent's object position (I'm talking about 1e-5) makes all children get jittery, and because the UI is attached to the player deep down the hierarchy, this makes it noticeable.

My controller is a custom character controller with rigidbody and capsule collider (my next step will be to try with an actual CharacterController, but before refactoring a good chunk of my code I wanted to ask here first). I decided this way because my character has to push objects sometimes (most of the time is spent walking on terrain, entering buildings sometimes or inside a vehicle, driving it).

I attach an image that shows the hierarchy and how the UI looks in the game:

#

The solutions I have seen so far are:

  1. rendering with a secondary camera (like if this were an FPS weapon, setting masks and so on). I am not very keen on this idea - I have been avoiding it from the beginning.
  2. simplifying the hierarchy (it seems there are rounding errors in matrix multiplication which cause the jittering when you go down too far in the hierarchy).
  3. trying with unity's character controller and adjusting variables to avoid jittering (which I have no idea if would work on this setup).
  4. perhaps instead of just parenting the UI to the camera > head > player I could follow the position of the object and smooth out the average of the movements to add small organic movement and kill jittering (not sure if it would work)
#

Any ideas are welcome!

tranquil sonnet
#

I found a temporary solution: created a script that when the player gets away X units, it just moves everything back to zero. there is no jittering visible and works in all cases (inside vehicles, outside, etc). the only issue is that this is forcing me to keep all objects dynamic (which is something I was already doing - for other reasons). This solution broke the skybox shader (one I bought from the store) but that's outside the scope of physics 🙂

If anybody has another solution for this I would love to hear it anyways!

devout token
floral fossil
#

For some reason two 2D objects won't collide. When I set one of the colliders for the "Hiding place" object to trigger, OnTrigger2D works, but the player object just goes straight through the other collider. I included the Inspector for both objects in case that helps

tranquil sonnet
timid dove
#

That's what trigger colliders do.

#

If you want a physical collision don't use a trigger

floral fossil
#

No, what I'm saying is there's a collider set to trigger and one not set to trigger on the same game object. Collisions seem to be registering on the one set to trigger but not the one not set to trigger

timid dove
#

Unlikely

#

You're probably just misinterpreting the situation

floral fossil
#

I'll see if I can screen record and show what I mean

floral fossil
#

I've found the problem. For some reason, the colliders stop working when the Player object's rigidbody is set to kinematic

timid dove
floral fossil
#

Ah, I wasn't aware of that. Thanks!

summer flare
idle sluice
#

Hey guys - I've got a 2D Physics issue. When Mario walks across this row of five blocks up here, he trips up and goes airborne for a brief moment - getting about two pixels of height. I have to wonder why this happens, since the blocks are all 1x1 colliders flush with each other, but I also understand that it could just be some weird Unity quirk I'll have to live with. My question is: is there a workaround? Could I use a CompositeCollider2D on these blocks and keep their scripts in tact? Question-Blocks reveal items, and Bricks get destroyed.

#

Mario's collider has an oblong octagonal shape. It must be the sloped edges at his feet that are colliding with the corners of the blocks, causing him to trip. I'd prefer not to change the collider itself, if possible, since it's (a) a composite of two polygon colliders which would be really annoying to change and (b) the optimal shape for terrain interaction.

lilac kelp
# idle sluice Hey guys - I've got a 2D Physics issue. When Mario walks across this row of five...

Sign-up to get the free demo at http://prettyfrenchgames.com
Wishlist my game if you liked the video: https://store.steampowered.com/app/1490870?utm_source=youtube&utm_content=char-stuck-tutorial

First tutorial video about a common issue with 2D collisions in Unity. Hopefully this gives a good solution when a box collider 2D get stuck in ground...

▶ Play video
idle sluice
#

ok yeah but

#

will this work for blocks that are supposed to have different interactions

timid dove
idle sluice
#

uhhhhhhhhhhhhhhhh

idle sluice
#

I have different things in the blocks

#

like coins and items and all that

#

Can I attach the gameobject without a collider to the tilemap somehow

rose lion
#

Hi Guys

#

this water pipe is procedural, and whereever he goes dragging the pipe, it gets longer and follow the line, how is it possible to implement it in unity?

#

is there any tutorial on this?

timid dove
#

You'd basically make the spline following the character and then procedurally generate your mesh around the spline

orchid path
#

If I need to enable my collider only in certain conditions, would it be faster to

Physics.IgnoreCollision(collider1, collider2);

or to (needs a second collider due to the nature of my system)

collider.enabled=enabled;
rocky thistle
#

guys I am stuck. I'm trying to read the current X axis rotation of an object but its outputting wrong data. Im trying to read angles between -15 degrees to 15 degrees but it giving me 345 to 15. I've tried to make an if statement that says "if the angle is between 345 and 360, do currentAngle - 360" but now the angles range from -345 to -15.

#

what im trying to do for context: balancing this beam using physics engine. Everything works except this angle bs

#

also sometimes, ill change one part of the script, maybe remove a comment and then the script works slightly differently and that is just confusing

timid dove
#

Euler angles are not unique and are subject to gimbal lock

#

It's hard for me to say which parameters to put in exactly without understanding the orientation of this object in the world better.

rocky thistle
#

I got it working bro, thank you so much!

wispy marten
#

Hello everybody! How you doing?

I am an automation engineer, trying to use the URDF IMPORTER package...

I am complete noob on unity...

Is anybody accostumed to It?

I seem to be having a null reference problem with One of my .STL meshes.

The URDF model works Just fine in other environments...

rocky thistle
#

Unity's Line Renderer Component doesn't work in the UI system... So, let's create one that does...

Interior Mapping Shader - https://www.youtube.com/watch?v=dUjNoIxQXAA
Photo Real Assets - https://www.youtube.com/watch?v=Y538_YYhC1A
Fixing Grid Layouts - https://www.youtube.com/watch?v=CGsEJToeXmA
-----------------------------------------------...

▶ Play video
#

hey guys, so i was following this tutorial but the "graphic" class at 1:59 doesn't work in unity 2021.3.19f1

#

people said to add a canvasRenderer but it still doesnt work

#

can anyone suggest a solution? Thanks

timid dove
#

Also what does this have to do with physics

rocky thistle
# timid dove Wdym by "doesn't work"

At the top of the script u usually see; script name : MonoBehaviour but replacing MonoBehaviour with Graphic like the video says doesn’t work.

rocky thistle
inner thistle
#

Again, "doesn't work" means what? Do you get an error message?

rocky thistle
#

It doesn’t recognise Graphic as being a real thing

#

I get an error saying something like: this class doesn’t exist(are you missing an assembly reference?)

inner thistle
#

"...or a using directive"
Did you add this like in the video?

rocky thistle
#

Yes I am, but UI also doesn’t exist

#

I believe it’s my unity version number but everyone seems to be fine in the comments of the video so it suggests that the code still runs well in newer versions of unity

inner thistle
#

Show your code and the full error message. Copy-paste, don't paraphrase

rocky thistle
inner thistle
#

Do you get the same errors in the Unity console?

timid dove
rocky thistle
#

how do i do that?

timid dove
#

Edit - external tools - regenerate project files

rocky thistle
#

ah got it

#

ill try it and let u know

#

nope, didnt work

#

I think it has something to do with my unity version number

inner thistle
timid dove
#

Is the UI package installed?

#

Also nitkus question

rocky thistle
#

btw mb i didnt see ur message there Nitku

inner thistle
#

Then it's a VS issue

rocky thistle
rocky thistle
#

is it what PraetorBlue suggested about the UI package?

timid dove
#

Regenerate project files is the usual solution

timid dove
inner thistle
#

If it doesn't throw errors in Unity then the UI package is installed

#

Close both VS and Unity, delete the project's library folder, reopen Unity and then VS

rocky thistle
timid dove
#

Actually upgrade all of your outdated packages

rocky thistle
#

hopefully it works

#

thanks for bearing with me so far

rocky thistle
#

cuz how do i get my project back then...

inner thistle
#

The Library folder, not the entire project

rocky thistle
#

same problem

#

deleting the library folder didnt fix it

lilac wedge
#

Hello, I'm making a 3D game with floor tiles as a primary mechanic. Those floor tiles may be in set up in an arbitrary shape, and I would like for every shape to have possibly a single 3D collider (used for triggers, not collision).

In 2D I would achieve that very easily with an edge collider - each tile shape would have a different set up of a single edge collider. How can I do that in 3D? Mesh collider was my first idea, but that would require me to create a mesh for each tile shape in the game - so I would have to do hundreds of additional meshes... that's a very clunky solution.

#

I could maybe give each tile a separate Box Collider, but then is there a way to compound/composite all those colliders into a single one? So that I don't generate thousands of box colliders in to the scene unnecessarily...

split solar
#

I'm stuck on a severe physics bug in my game's level editor

#

In my game, the user can draw procedural meshes into the level that get Mesh Colliders attached to them

#

They can also attach decorative objects to these meshes, that are spawned in as child GameObjects but with no physics colliders on them

#

And what's happening is

#

The game sets things up like so:

Physical Group (rigidbody)
  LevelObject (drawn mesh, collider)
     Ornament (decorative mesh, no collider)
#

When the player initially places the drawn mesh, and quits brush mode, everything works fine and the platform falls to the level floor

#

If they then place the ornament onto the mesh, it still works fine

#

But once they grab ahold of the existing object, drag it around, and let go of it, gravity completely breaks

#

If I pause the physics simulation, disable the ornament GameObject, then resume the simulation, it's still broken

#

But if I then grab the object again with the ornament disabled, and release the object, gravity works again.

#

What i've found is, just having that child ornament attached to the object is enough to make the physics system freak out and I'm not sure why. A GameObject with just a Mesh Filter and Mesh Renderer shouldn't be contributing to the physics world, right?

#

When it breaks, I've seen only one side of the object fall to the ground. I've seen the object clip through the ground. I've seen it levitate toward the sky. I've seen it start rotating in place for no reason.

#

It's really unpredictable but either way I just wanna know why this is happening

split solar
#

nvm, after debugging, I've figured out what's causing it

#

It's another collider that's set up to follow the Ornament, but it's on a layer that collides with the LevelObject, even though the ornament collider is only there for selection raycasts

orchid path
#

Why so much difference in behavior ?

        if (Input.GetKeyDown(KeyCode.Z)) myOwnGravity = !myOwnGravity;

        if (myOwnGravity)
        {
            frame.rigidbody.useGravity = false;
            frame.rigidbody.AddForce(Physics.gravity);
        }
        else
        {
            frame.rigidbody.useGravity = true;
        }
inner thistle
#

is that in Update or FixedUpdate

orchid path
#

Fixed

inner thistle
#

and what's the difference?

orchid path
#

Nvm I needed to add Forcemode.acceleration

timid dove
orchid path
#

i know

split solar
#

I'm getting really frustrated that OnTriggerExit is severely broken when working with mesh colliders

#

OnTriggerEnter is reliable but OnTriggerExit isn't

acoustic pond
#

wsppp

timid dove
#

I've never had a problem with it.

#

the only time it doesn't work is when you disable or destroy the object instead of it moving out of range.

split solar
#

I have never had this work reliably

#

Unless it's specifically to do with concave mesh colliders, but

#

I can't just....rely on all colliders being convex

#

I don't have a way of splitting a concave mesh into multiple colliders at runtime

#

There doesn't seem to be a built-in way of doing it in the engine

#

And I'm tired of dealing with this

timid dove
split solar
#

I'm aware

#

I didn't say the trigger was concave

#

The colliders that I'm trying to watch enter and exit the trigger are

#

And they're the ones I can't reliably set as convex, because some of those meshes are created by the player and I don't know what they are until the player creates them

#

And it's not even like I'm dealing with rigidbodies yet

timid dove
#

if there's no rigidbodies then you won't get any trigger messages regardless

#

but yeah I'd probably look into writing or finding an algorithm to split the mesh into multiple convex meshes and.or primitives for the collider(s)

split solar
#

I'm only trying to figure out if a brush object is overlapping some other physical object, so I can block placement of a new object with the brush, or if it's a procedural brush blocked by a procedural object, allow the player to paint onto the existing procedural object

split solar
timid dove
#

yeah would almost definitely try to use direct physics queries for that rather than waiting for trigger callbacks

split solar
#

Like this is a common-enough use case that I'd expect the engine to support it

split solar
#

I don't even know how I'd write an algorithm that can accurately but quickly check if two meshes of any shape have any intersecting triangles

upbeat vessel
#

@scenic skiff if you disable the wall and let it hit the player capsule collider, what happens?

scenic skiff
#

hang on the capsule is tiny so this might take a sec to test

#

same basic behavior, ball loses all velocity towards player and retains sideways drift

upbeat vessel
#

But the wall is the player, right?

#

So it doesn't gain velocity away from the player

scenic skiff
#

the wall is a 3D box attached to the player

#

the capsule is part of the first person controller prefab

#

Bumper is the box

upbeat vessel
#

What's the mass of ball and the mass of the bumper?

scenic skiff
#

ball mass is 1

#

box doesn't have a rigidbody to have a mass

#

the capsule has a mass of 1

#

the capsule is FirstPersonController, the root

upbeat vessel
#

Add a rigid body to bumper

#

Set it to kinematic

scenic skiff
#

balls now phase through bumper entirely

upbeat vessel
#

Is there a collider on the bumper?

scenic skiff
#

okay did another test

#

phases through when going fast

#

slow impacts functon without the velocity killing bug

upbeat vessel
#

Uncheck is kinematic and increase mass to 5

scenic skiff
#

cube floating away into sunset

upbeat vessel
#

Lol

scenic skiff
#

will move with camera but is no longer locked to player

#

attempting this

upbeat vessel
#

So it needs to be kinematic

#

Might work

scenic skiff
#

box locks to player again

#

new behavior

#

will collide with box when player is still, if player is moving no collision

upbeat vessel
#

Yeah, it needs to be kinematic

#

Your on the right track now, might wanna look up a tut on pool/billiards because this getting outside of wheelhouse

scenic skiff
#

set it back to kinematic, no collision when player is moving quickly

upbeat vessel
#

I think the speed of the ball is getting out of hand, you might need to use real-world mass to tame the velocity.

#

I gotta run some errands, I'll check back with you in a couple hours if you don't mind. In the mean time, If you find a solution, I'd like to know what it was.

scenic skiff
#

I'll work on it

scenic skiff
scenic skiff
upbeat vessel
#

You have continuous or discrete on the ball?

#

@scenic skiff

acoustic pond
#

heyy

upbeat vessel
#

Hi

scenic skiff
acoustic pond
#

uhmm i need help w my active ragdoll but idk if this is the like

#

place

#

?

upbeat vessel
#

Is it code related? Go-to the respective code channel..

acoustic pond
#

nooo, not code related

#

i found the issue

acoustic pond
#

the issue b back fr

acoustic cipher
#

Guys, default gravity value in the editor is set to be close to earth, right?

#

Also, rigidbody is meant to simulate physics and while i set mass of an object to 100 kg and hit jump by applying force it falls donw like on moon. That Rigidbody mass value not even influence how fast object fall no matter if it is 100 kg or 100000 kg which is beyond me, known bug or i dont know what, confused.

inner thistle
#

Famously gravity affects all objects the same regardless of their mass

#

you have something that interferes with the velocity, show code

acoustic cipher
# inner thistle you have something that interferes with the velocity, show code

'using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public Camera mainCamera;
public float moveSpeed = 5f;
public float rotationSpeed = 200f;
public float jumpForce = 5f;
public LayerMask groundLayer;
public float groundCheckRadius = 0.1f;

private Collider playerCollider;
private bool isGrounded;
private Rigidbody rb;

void Start()
{
    playerCollider = GetComponent<Collider>();
    rb = GetComponent<Rigidbody>();
}

void Update()
{
    CheckGrounded();

    float moveHorizontal = Input.GetAxisRaw("Horizontal");
    float moveVertical = Input.GetAxisRaw("Vertical");

    Vector3 moveDirection = (mainCamera.transform.forward * moveVertical + mainCamera.transform.right * moveHorizontal).normalized;
    moveDirection.y = 0;

    if (moveDirection != Vector3.zero)
    {
        Quaternion targetRotation = Quaternion.LookRotation(moveDirection);
        transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
    }

    if (isGrounded && Input.GetKeyDown(KeyCode.Space))
    {
        rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.z);
    }

    Vector3 movement = (mainCamera.transform.forward * moveVertical + mainCamera.transform.right * moveHorizontal).normalized;
    movement.y = 0;

    transform.Translate(movement * moveSpeed * Time.deltaTime, Space.World);
}

void CheckGrounded()
{
    Vector3 groundCheckPosition = playerCollider.bounds.center - new Vector3(0, playerCollider.bounds.extents.y, 0);
    isGrounded = Physics.CheckSphere(groundCheckPosition, groundCheckRadius, groundLayer);
}

}'

inner thistle
#

You're mixing physics-based movement with manually setting the transform position. You can't do both, you'll have to choose which one to use and only use that

acoustic cipher
inner thistle
#

If you do it correctly, yes

timid dove
#

this is a fact of physics

timid dove
acoustic cipher
#

Yeah, air resistance

timid dove
#

there is no air resistance in Unity (or on the moon)

#

there is a rudimentary "drag" field on Rigidbody, but this doesn't take into account anything about the "air" or the size or shape or mass of the RIgidbody.

acoustic cipher
#

i mean when comparing a stone ball with feather where feather will fall slower cause it has greater air resistance

timid dove
#

sure but air resistance is not simulated in Unity

#

so in Unity, they will fall the same speed

acoustic cipher
#

But what i can set in unity to have object fall faster

timid dove
#

Or add your own additional gravity force to it each FixedUpdate

#

or use a ConstantForce component to do that for you

acoustic cipher
#

Oh ok, will look into that

#

Thx

timid dove
#

Or if you're in 2D there's a gravity scale on each Rigidbody2D

#

lots of options

acoustic cipher
#

Yeah i know about that gravity scale per rigidbody2d but i'm about 3D which lack this option

coarse falcon
#

hey, can someone help me with a little issue on the game im creating on unity?

#

i'm programming the bird and it looks weird when it falls... like you have to click more than one time to contrarrest the force of the falling, the same when it goes up... it duplies the force or something like that

#

this is the code

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
    [Tooltip("The force that makes the bird ascend")]
    public float impulse;

    public Rigidbody2D rb;


    void Start()
    {
        
    }

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector2 fuerza = new Vector2(0f, impulse);
            rb.AddForce(fuerza, ForceMode2D.Impulse);
        }
    }

}
scenic skiff
#

default is 10, balls velocity is 20 and max player speed is also 20 for 40 total, turning it to 30 massively reduced the issue and 45 eliminated it completelyt

timid dove
#

the higher the number, the stronger the impulse will be

twin quarry
#

Hi, I've just noticed that there is an option to run Physics2D in multithreaded mode. In the docs it says it will "executes the simulation steps using the job system". So FixedUpdate will still run in the main thread, but the actual physics calculations that are run in a separate thread, right? But stuff like OnTriggerXXX depends on the result of the physics calculation so it needs to wait for the result of the calc. In that case something like
Update -> FixedUpdate -> Update -> Update -> Update -> OnTriggerXXX could now be possible, since the updates can continue to run while physics calculation is taking place. Are there any docs going into detail how the execution order is affected? And is there any reason NOT to do this? It's disabled by default, but this could be big for performance.

timid dove
#

Certainly worth testing though to be sure

zinc terrace
#

is there a way to make a rigid body object have a rigid body child but attached to the parent?

timid dove
zinc terrace
timid dove
#

I have no idea what I'm looking at here

#

or what the issue is

zinc terrace
timid dove
zinc terrace
# timid dove I don't see any reason you would need a rigidbody on the child for that to work
    {
        if (Physics.Raycast(transform.position, transform.forward, out hit, maxDistance, ~ignoreLayer))
        {
            if (hit.transform.gameObject.tag == "Toilet")
            {
                var destroy = hit.transform.gameObject.GetComponent<ToiletBehaviour>();
                destroy.hitsReceived++;
                Instantiate(decalHitWall, hit.point + hit.normal * floatInfrontOfWall, Quaternion.LookRotation(hit.normal)).transform.parent = hit.transform;
            }
            if (hit.transform.gameObject.CompareTag("WeakPoint"))
            {
                hit.transform.GetComponentInParent<ToiletBehaviour>().hitsReceived = hit.transform.GetComponentInParent<ToiletBehaviour>().maximalHitsToDestroy;
            }
         }```
timid dove
zinc terrace
#

i added it a collider and nothing

#

but i added the rigidbody it works

timid dove
#

Did you use Debug.Log?

#

Did the code run?

zinc terrace
timid dove
#

I know

#

I'm telling you when things aren't working you need to debug

zinc terrace
#

oh ok

timid dove
#

it's because you used if (hit.transform.gameObject.CompareTag("WeakPoint"))

#

hit.transform will give you the Transform of the rigidbody

#

if there is one

#

on the parent for example

#

you should use if (hit.collider.CompareTag(

zinc terrace
#

oohhhhhhhhhh aghhhh

#

ahhhh it works now

#

thank you so much 😘

scenic skiff
#

I'd like to be able to predict and display the path of an object moving in a no-gravity environment as it bounces off stuff, is there a particular way I should get started in learning how to do that? Looking for a jumping off point

fierce rapids
#

hey im making a vr game where i walk on my hands and im using the configurable joint and a sphere collider to get a sprinngy feel but i would like to have the rotation on the springs stiffer so i dont slide on the ground or slip off walls. anyone know how to fiks this? here is the video

uneven shore
#

hey guys - where do you recommend to put collision detection?

I know FixedUpdate should be used for collision, but Update is used for actually moving (Transform.Translate), so I'm not sure.

timid dove
uneven shore
#

@timid dove why not?
And I'm doing everything manually; I'm detecting the collision using rays

devout token
#

There is no "average case" and it also depends on the type of collision detection

uneven shore
#

@stuck bay it should be the same width of the wall.
If you see the player still goes through it, you can use Continuous collision detection, rather than the regular Discrete.

acoustic pond
#

wasssuhh

#

can any1 help me set up a active ragdoll? ive tried from following tutorials, to swapping models and stuff but i can't seem to get it to work.

#

i can even setup a normal ragdoll using gameobject > 3d > ragdoll, and it works completely fine, but then swapping the joints to smthing to configurable, and simply adding force and stuff and connecting everything, it breaks

scenic kayak
#

Hey, quick question.
Planning on making a very complicated game that has only been simulated once before.
Q.: Who has ever/Has anyone ever made a very close to irl physic simulator for (e.g.) Bicycles, Motorcycles, etc.?
And if not, would it even be possible to make and run it on high fps to be able to compete in the eSports niche? thanks

maiden burrow
#

Hey, does anybody know, why my objects doesn't collide with each other? I have this spaceshooter 3d where my spaceship goes through everything.. I don't know why. It has all colliders and also those asteroids have colliders. But it just keeps going through everything. Please help me

#

i have tried collision detection at all settings but it doesn'

#

t work

#

also the asteroids go through each other

hollow gazelle
#

how to check if 2 square colliders are colliding

#

istouching didnt work

trim ore
maiden burrow
trim ore
maiden burrow
#

method onCollisionEnter is never called

trim ore
#

ie transform.position = etc..

#

in code

maiden burrow
#

void Thrust()
{
thisShip.position += thisShip.forward * boostSpeed * Time.deltaTime * Input.GetAxis("Throttle");
}

#

void Turn()
{
float yaw = turnSpeed * Time.deltaTime * Input.GetAxis("Horizontal");
float pitch = turnSpeed * Time.deltaTime * Input.GetAxis("Vertical");
float roll = turnSpeed * Time.deltaTime * Input.GetAxis("Rotate");

    transform.Rotate(pitch, yaw, roll);
}
trim ore
#

right that wont give you collision

maiden burrow
#

ok

trim ore
#

change theShip to a rigidbody type

#

then use
thisShip.velocity

#

you might need to lock in the proper constraints on rigidbody component, like Z pos

maiden burrow
#

ok

trim ore
#

kinematc is also an option but use .MovePosition() method

maiden burrow
#

now it's not moving anywhere

trim ore
maiden burrow
#

public Rigidbody thisShip;
public GameObject ProjectileFab;
public Rigidbody r;
public Transform projectileSpawnPoint; // Lisätään spawn-piste ammuksille
public ParticleSystem engineFlames;

void Thrust()
{
thisShip.position += thisShip.velocity * boostSpeed * Time.deltaTime * Input.GetAxis("Throttle");
}

#

public Rigidbody thisShip;

trim ore
#

hmm so you didn't use .velocity like i said

#

also is it kinematic or not

maiden burrow
#

rigidbody is not kinematic

trim ore
#

and where are u calling thrust

maiden burrow
#

in fixed update

trim ore
maiden burrow
#

now thisShip.forward is underlined

#

sorry, forward only

trim ore
#

myb

maiden burrow
#

ok

#

thisShip.velocity += thisShip.transform * boostSpeed * Input.GetAxis("Throttle");

#

did you mean like this?

#

thisShip.velocity += thisShip.transform.forward * boostSpeed * Input.GetAxis("Throttle");

#

?

#

so my spaceship doesnt still move

trim ore
#

btw if you're gonna do += I think you need to add * Time.fixedDeltaTime

#

you should also not have input in fixedupdate

rich tendon
#

Howdy folks. I've recently noticed the very basic physics in my game are consuming 90% of the CPU on mobile devices. The game is a top-down RTS, where units have rigidbodies to produce friction with the floor. If I have a single unit just standing around the physics usage is nothing. If it moves at all the physics computations go through the roof. Adding more NPCs doesn't seem to affect this much. On a fast PC I can do 1000s of units without any slowdown. Its just the first that makes a nice hit and only when it is moving.

#

I must have done something fundamentally wrong with the setup but I can't seem to figure it out.

trim ore
#

thisShip velocity thisShip transform

rich tendon
#

Note - this isn't making use of colliders during the movement.

maiden burrow
rich tendon
#

I had read in one place that you shouldn't have a GameObject with a collider and no rigidbody assigned. In this case I have a GameObject NPC with several child Gameobjects, and some of those have circle colliders on them without an additional rigidbody. Could that be causing an issue?

orchid path
#

Does it not matter where parent pivot is for physics of children?
I think if i set RB.centerofmass manually then there should be no problem even if parent pivot is few meters further ??

dense tartan
#

looking for help with some buoyancy physics. i found this (seemingly) great pipeline that has an outdated tutorial i'm trying to get to work. has anyone used this? :https://www.habrador.com/tutorials/unity-boat-tutorial/2-basic-scene/

#

/ does anyone have a buoyancy phys tutorial or script they'd be willing to share?

rich tendon
#

It appears if I turn off several interaction layers the performance improves a little. It is only ever going to interact with the floor and maybe the walls, but I'm still not happy with the hit for floor interactions. I saw a good writeup and forum discussion that really seemed to indicate that child gameobjects don't/shouldn't get their own rigidbodies.

#

This isn't a physics minded game so I may turn down the sim step size a bit more.

junior thicket
#

My physics are behaving weird and difrent when i build the game compare to the editor, is that a common issue ?

timid dove
dreamy fiber
#

Respected,
I want to move the gameobject forward and slightly upward too and rotate slightly in the local y-axis (with rigidbody add force)...
when user finger swipe up the screen.. please guide

scenic kayak
inner thistle
#

I don't understand what you're asking exactly

#

I mean yes, it's possible to replicate what someone else has done, that's only up to your skill

scenic kayak
#

It has not been done in Unity before.

scenic kayak
inner thistle
#

There's nothing that could be done in other engines but not in Unity so again, up to how skilled you are

scenic kayak
#

I haven't seen any good Motorcycle Physics wip videos in Unity

mortal apex
#

Also, does anybody know any reasons why my RBs are looking jittery? They look absolutely fine from a fixed angle but when tracked with a camera their movements are jittery? I can attach a vid if i've explained this awfully

scenic kayak
#

Aight, i'll continue to look for other engines that suit my needs better
Thanks tho

timid dove
#

that's a specialized thing that will naturally require third party libraries or a custom physics implementation, regardless of which game engine you use.

#

Note that the game engine used by BeamNG (Torque) ALSO only implements Rigidbody physics. In fact they use the same physics engine as Unity (NVidia PhysX).

devout token
mortal apex
#

I think I'm just going to mess around with it for a few days, that always seems to work lmao

devout token
zinc terrace
#

guys, a question, how do I prevent my objects from crossing my map floor like in gmod? In gmod, if you force a lot, the collision of an object with the ground does not cross it

timid dove
hidden token
#

Simple question cause I forget how the different colliders work in Unity. My player is currently passing through mesh colliders, and for some reason jumping isn't working, but I suspect it has something to do with the mesh colliders. My player is also floating and doesn't seeem to have any actual gravity

#

Also, when I check "isGrounded" it unchecks as soon as I click play

sage yoke
#

does someone have a clue on what's changed between each version of physx?

sage yoke
#

it should fix passing through objects

#

and remove iskinematic for most of the use cases, if an object is kinematic default gravity will not affect it

sage yoke
#

tbh i've read a lot of documentation but i never found the issue

light anchor
#

Is this video accurate?

#

what’s exactly the problem in the falling example?

#

idk just do some more scripting

#

add trigger colliders to do detect when you’re getting close to the ground or shoot ray/shere casts

rich tendon
light anchor
#

I don’t trust Unity that much, well I don’t trust Unity at all

#

I mean in regards to the engine part

rich tendon
#

Yeah, you've just described all technology created by man 😛 Still, we have to try our best haha..

#

I can see why the lack of a rigidbody may create additional computation. Just not in a position to setup my own benchmark at the moment, and why reinvent the wheel if someone has the knowledge already.

light anchor
#

I had to spend two days writing my own mesh scanner to detect whether point is inside non convex mesh collider or not because Unity removed all options to check it lol

rich tendon
#

The performance hit in the engine for a single dynamic rigidbody interacting with a tilemap is much higher than I'd have thought.

#

My past engine experience was Torque 2D, and I never had to consider physics as source of high computation for an RTS style game.

light anchor
#

I don’t use dynamic rigid bodies in my game at all but I’m surprised by how many rigidbodies Unity can handle honestly even on mobile

rich tendon
#

Well on iOS devices, yeah.

light anchor
#

around 1200 and it runs pretty smoothly on snap 778

rich tendon
#

I often feel like my iPad is as performant as my desktop

#

But my Android devices all feel lobotomized.

light anchor
#

cheap ones do

#

maybe Samsung if it’s on exynos

rich tendon
#

Nah, Adreno CPUs

#

Just a single point light likewise kills performance. Its just strange, and I'm not sure what it all means yet. Torque really didn't have such issues on the same devices, but its a dead engine at this point.

gilded bay
#

hello
how can I make 2d sprite jelly physical soft body?
any 'official' and performance friendly solution?

sage yoke
sage yoke
sage yoke
#

also the relative velocity of the collision is the same, but the actual velocity after impact is different

rough pivot
#

hey guys! haven't really worked with physics yet, but i'm trying to get a somewhat accurate simulation of bouncing/rolling ball going... the main issue so far is, that rotational drag is only a constant - but i need to somehow make it dependant on the second material (i.e. a ball rolling on 'grass' is slowed down more than a ball rolling on 'concrete')

first workaround idea was to freeze the rotation of the ball and just let it slide around the surfaces with different friction values in the different ground physics materials - is that a viable solution?

any ideas and pointers appreciated, or some links to resources that go a bit deeper than the basic tutorials...

timid dove
steel sorrel
#

Is it good practice to separate the rigidbody from the actual mesh, to be interpolated in Update instead, while leaving the rigidbody with interpolation disabled? ... because, I see now that Interpolation causes Additional performance costs when updating the position of a character for instance, I assume it is syncing the transform, even if you disable said feature ( probably to average the interpolation with the desired new transform position) ... it will be quite a while to convert everything, and I litterally saw no one ever do this in manuals and tutorials

timid dove
#

Besides you interpolating it manually would also come with an extra cost

steel sorrel
# timid dove Besides you interpolating it manually would also come with an extra cost

yes ... and at least from my testing, QUITE the cost.

I can afford now to waste time on that, and most platform don't even care about this stuff,

but just "grabbing" two Vector3s rappresenting 2 transforms seem to cost as much as a raycast, of not MORE.

from my perspective, I would be smoothing something that the player mught not even notice it is stuttering, while making an AI agent "more blind and dumb" as he can read one thing less from the environment.

It'd love to just talk at lenght with someone at unity about it, but before I can do that I guess ai have to make 4k+ and become Pro user 😅

timid dove
#

Or prematurely optimize really. Rigidbody interpolation is generally cheap.

steel sorrel
# timid dove Or prematurely optimize really. Rigidbody interpolation is generally cheap.

maybe, but I do want to have that comversation at some point.

I feel that pretty much every asset uses both the physx and unity's libraries NOT in the way they were intended to be used, thus resulting in " necessary evils" that are totally avoidable.

One would think that with so many tutorials, everything MUST have been said ... but (professionally speaking) none of them are good, even the ones unity sponsors.

copper gazelle
#

Hi guys, I'm trying to detect when a Vector3 point from a point cloud is inside of an object using raycast, whats the best way of doing this?

rough pivot
#

unity physics hard 😭
how do i get the ball not stuck or bounce when rolling from one surface/collider to another?
alternatively - is there a way to use some sort of texture in a surface material to have different parameters on different locations of the same collider?

steel sorrel
timid dove
steel sorrel
plucky birch
#

is there away to have a special spherical collider attached to a ridgid body, that only colides with cloths?

plucky birch
#

can cloth also affect a rigidbody ?

#

or is the rigidbody only affecting the cloth ?

#

ah, only one way

robust kestrel
#

Does anyone here notice how Time.fixedDeltaTime runs a lot faster in the Unity Engine than the compiled Built version? Is there a way to synchronize the hz or something?

steel sorrel
#

at Unity engeneers, I just noticed ... is it the case that Convex mesh colliders are rebuilt every time they are moved, while non-convex mesh colliders aren't updated?

I'm doing some tests, and it appears to be the case?

robust kestrel
#

It might be faster visually but I had interlopation turned off on the rigidbody, but the collision detection in the editor is a lot less accurate than the built game

plucky birch
#

cause editor might run slower or even skips physics updates?

#

also don't select objects with alot of values changing in the inspector view, that tanks update times a lot

stuck bay
#

I’m not sure if this is the best channel to ask this in but right now i’m working on active randall made of multiple different meshes that are all separate rigid body’s attached by config joints.
i am trying to make them match the transform rotation of an animated character but it is not doing this and instead it’s acting like the transform values on the animated player are all staying the even the i can visually see them changing

#

is there any way to make said transform values actually change or should i use the automaticity made parts that do change(im using miximo for anims rn as i hate animating and it’s very early stage)

lucid mortar
#

Hello, a quick question regarding collider. If I have a simple cube and use a Mesh Collider, would the performance be the same as with a box collider ?

timid dove
#

It will be slower. But realistically you probably won't notice either way unless you have a large number of such cubes

lucid mortar
#

Got it, thanks a lot

solemn path
#

how do I stop two colliders from just pushing each other? I have two objects and I want their colliders to be able to overlap but they just push each other

dreamy fiber
#

Respected Seniors,
I am trying to move the gameobject down and forward and rotate in z-axis in world space (when user swipe up the screen)

and up & backward at which the face point (when user swipe down the screen)
with rigidbody addforce.
I have tried different approaches, but didn't find the accurate solution. The movement doesn't look like realistic.
Can someone please guide me via code or by ideas?
Note: I am already breakdown the task, but still doesn't know where I am doing wrong.
Thanks

steel sorrel
#

the fact that physics in unuty is not temporal is really a bummer 😞

at least my CPU is set up so that it overclocks when the load reaches a certain treshold.

well ... what that means? I means that I can use physX as G-d commanded and make the engeneers proud at my low CPU utlization ..

BUT ... all the physic in the game is calculated ALL AT ONCE!

Special "funny" case is that in a scene of a million objects, if even A SINGLE ONE has interpolation enabled, THE ENTIRE LEVELS GETS THE TRIGGER TO BE RESEIMULATED, EVEN IF YOU DON'T NEED IT.

No scene partition seems to be in place at the Simulate() stage 😞

#

in addition, enabling interpolation brakes the ability to do Raycasts in Update 😞

lucid mortar
#

Hello, I'm trying to add a simple rig to the player in the Third Person Starter Pack but I keep getting the following error

#

System.InvalidOperationException: The TransformStreamHandle cannot be resolved.

#

Here is my hierarchy

#

PlayerArmature

#

The aim contraint

#

I'm not sure what I'm doing wrong.

#

The process should be pretty simple from the documentation:

  1. Add a rigBuilder to the root which also contains the animator
  2. Add a child with a rig component
  3. Add a child to the rig with a constraint component
  4. Add a lookAt target for the contraint which the head will look at
#

I followed those step after loading the starter scene without touching anything else but this error keeps popping up

#

From Google, they say it's sometimes due to something in the Skeleton but I didn't touch it and there doesn't appear to be anything added in it

tired dagger
#

hello, does anyone know why the mesh coliders aren't working properly?

lucid mortar
kindred dawn
#

Please how can i remove the shaking effect who appear when my player enter in collision with a wall ?

tired panther
# tired dagger

I can't help you, but I have to ask
What are you trying to make?

tired dagger
tired panther
#

Ah

#

It looks a bit like a stylistic noodle (when zoomed out like that)

tired dagger
#

Yeah, without Textures or details you could even say it's a wand

prime ridge
# tired dagger

Anyone have an idea? Im working together with @tired dagger and it's using a convex mesh collider. Is it an issue that needs to be fixed in blender or in unity?

zinc urchin
#

Can anyone help me figure out why the lure isn't flopping around as it should when I move the fishing pole? As you can see, I have the rotation working, the issue is only with the motion.

EDIT: Nevermind, sort of obvious solution - the lure was a child of the pole so it was just sharing the same transforms

tired dagger
tired dagger
#

the colliders are doing some weird things

zinc urchin
#

Is there anything in Project Settings that will smooth this spring? I know the Damper setting is the obvious solution but it doesn't seem to help for these little oscillations.

EDIT...
Increasing the sphere collider size/tensor scale solved this. Awesome article that expands on this
https://blog.oimo.io/2022/08/28/calm-joints-down-en/

shr

Hi! This is the very first post in my blog in English.
I usually write articles only in Japanese, but this time I've decided to write the article in English as well, because I couldn't find any relevant post even in English. I hope this helps people who suffer from similar problems.

This is the Eng

uneven shore
#

I have 2 objects with rigid bodies:
(A) Kinematic, Discrete collision detection, Simulated, polygon collider 2d, gravity scale 1 or 3
(B) Dynamic, Discrete collision detection, Simulated, Box collider 2d, gravity scale 1.

In (A) I also have a script with OnCollisionEnter2D event.

When I set gravity scale of A to 1, it works.
When I set gravity scale of A to 3, it seems the trigger doesn't work - at least not the 1st time (it looks like a plate falling on the player).

Any idea how come and how to solve this?

steel sorrel
#

i'm doing things to perfection, but the physic engine being calculated all at once is something that I cannot change ... my "solution" to keep track of colliders and enable only the ones close still cost me performance ... in fact, the act of "checking" either per single collider or that collider self-chekcing the are it is in COST THE SAME as keeping physics enabled 😦

#

In addition, if I implement a custom physic solution, a temporal one, for each collider I would "wake up" the ones close to it ... well, that accomplishes the Physic load being constant and spread out, BUT now the load is increased and not as optimized

devout token
steel sorrel
#

if you want to do simple stuff, much of its design goes against you ... that is, it's still nothing, it's 1 millisecond, and no computer in the world will run the game that fast, expecially as I throttle it intentionally

#

it's just a bit depressing ... that areas of the same scene cannot exist on their own separate simulations ... people suggest multiscenes, but as far as I am aware you cannot call a Simulate() that only works on one scene ... yes?=

zinc urchin
uneven shore
#

@zinc urchin the thing is, when I wrote "Discrete collision detection" - in my mind I thought about continous. It's also why I pointed it out 🤦‍♂️

Thanks, will do!

zinc urchin
uneven shore
proper sluice
#

how come when i hold D to move to the right my player is pushing into the wall's collider shown in the top pic? when i release it gets pushed back to where it should be like the bottom picture

    private void FixedUpdate()
    {
        Vector3 movement = new Vector3(horizontalInput * moveSpeed, rb.velocity.y,0);
        rb.velocity = movement;
    }

this is how i was moving it

steel sorrel
tired panther
#

Why -rb.velocity?

timid dove
zinc terrace
#

Hey guys, how can I make sure that if my object has a child and both have mesh colliders, the colliders ignore each other? (I'm talking about not mixing or crossing each other)

#

the neck is crossing the mesh collider

#

but i want to make that the object
make a hole in it to the big collider with the other collider so that it is not inside

#

idk if i was clear xd

solemn path
zinc terrace
#

Wait,but i want to change the collision form with the head

#

In my case they are sticked

#

I want to do that the head collider do an aperture on the toilet mesh collider so they are not sticking

#

for example, in a river, when the water passes and there is a wooden stick in the middle, the water does not go through it but rather passes through the sides, preventing them from pooling together

#

The stick is the head mesh collider and the river is the toilet mesh collider,i think that you understand it

grizzled jacinth
#

@sage yoke

Unity4 Physx (2.7) to Unity2020
so you are looking to run an older version of physx in a new version of unity, instead of the more recent physx included with unity 2020?

while not impossible, implementing an old physx runtime would be a massive amount of work for apparently no benefit.

what are you looking to do here? preserve physics bugs from old version for speedrunners or something? there's an extremely small number of possible edge cases here.

sage yoke
#

sadly it's not the only problem, but it's the more noticable

grizzled jacinth
#

@sage yoke i'm not sure if there is an example around using the older sdk (worth a search,) but you may be able to downgrade this to physx 2.7 sdk or possibly even just patch in only the code from 2.7 into 4.x that you care about: https://github.com/NVIDIAGameWorks/UnityPhysXPlugin

GitHub

Experimental Unity package to enable access to NVIDIA PhysX SDK 4 from within Unity. - GitHub - NVIDIAGameWorks/UnityPhysXPlugin: Experimental Unity package to enable access to NVIDIA PhysX SDK 4...

sage yoke
grizzled jacinth
#

to rule out this specific change in 2020.2, you can try an archive of unity 2020.1

sage yoke
#

the problem happens as soon as i switch to unity5 with physx3

#

i'm not sure about it but i guess that in unity4 there was a limit on the velocity after you collide with an object which is not present in later version of physx

sage yoke
#

even tho pretty much will be a pain to understand anything in that lmao

#

also just for being sure i even check the relative velocity of the collision itself, and it's identical in both version, but for some reason i lose less speed

grizzled jacinth
#

physx is a pretty large codebase, i've dove into plugin dev once before with it though i don't remember much lol... you might be able to graciously ask the nvidia physx devs for some advice or look at the other devs that have forked this repo and have gotten familiar with it

sage yoke
#

i'm gonna try, thanks ❤️

past phoenix
#

I have a problem with overlapping rigidobdies. I have a container full of boxes (3d) and each of these boxes experiences a force that pulls them towards the center. The problem is that the boxes in the closer you are to the center, the boxes overlap more (because they experience more force due to more outside boxes squeezing them i assume). Is there a good efficient way to avoid this overlap?

zinc terrace
#

How can I make sure that if I have a parent object with mesh collider and another child object also with mesh collider, they stop wobbling? (I get that error)

#

Also is there a tutorial for make an entity that do different things when shoot in vital points? Eg: if i shoot to the head it leaves the body but if i shoot the body it explodes

#

I trying to do that with mesh colliders but has several bugs

woven oxide
#

Hi is there any relatively easy way to make a multi-sprite character with some hanging cloth items have the cloth obey physics with regards to the body parts underneath?

for example, in the image i'd like that cloth on the leg to wrap around the leg on the left side when it bends
Image
would easiest way be to use the physics engine, give both objects colliders and give the leg an RB?
then use a FABRIK solver on the cloth?

#

I have IK Limb setup on the legs as well

woven oxide
#

I was able to "sorta" get it to work by faking physics using the FABRIK solver, and setting the pivot point on the knee bone for the fabric. It breaks at extreme angles of motion but its sufficient for my animations

#

no colliders or RBs used

proper sluice
#

when the red block player rides the purple platform that moves up and down, when he gets to the ceiling (light blue block) he gets pushed through it to the other side. i think id like the player to maybe die in this case, how should i check and handle for that? raycasting out the top of the player?

woven oxide
#

you could use raycasting but probably colliders would be good?

#

you can use triggers on the colliders and hook up a rigidbody to the player

#

so when the player hits the other block, trigger a death and destroy the player object

lime musk
#

Hello Good Day everyone!
i have Problem with my character.
i tried to humenoid it BUT.... im getting this error !

#

ichecked the bone mapping and everything was fine

#

and even created a new avatar.

#

also checked parenting in blender

#

but still dont know what to do

#

Please help!!!

coral mango
sick wharf
#

okay so in ONE SCENE physics dont work at all

#

rigibodies aren't affected by gravity in this one scene and i have no clue why

#

theres nothing in there that sets the gravity or timescale to 0

#

the physics objects are not marked as static

#

the global gravity is a non-zero number

#

whats going on???

sick wharf
#

please i really need help

timid dove
sick wharf
#

i fixed it

#

turns out fishnetworking was forcing the sim mode to script

timid dove
#

yep

#

network frameworks almost always do that

#

because they need to control the physics sim and do rollbacks etc

vague fjord
#

Hello! Bit a problem here! I'm trying to simulate balloon like bouncy physics for a character as a visual effect, I don't want this logic to affect the movement in any way

#

The thing is that, If I connect the RB and HingeJoint to the main RB, even with mass 0 it has some effect

timid dove
vague fjord
#

Uhh Ill try that! 👀 thanks for the help

vague fjord
dense veldt
#

Is there a reason that AddForce will work fine on one "grounded" collider but go very slow on another collider of the same type? Both are the same objects with the same parameters.

#

Thats so weird.

#

Okay, I moved it even lower and now it's working.

#

For some reason, at 1.9, it doesnt move hardly.

#

But I move it even a little bit up or down, it works.

#

I also tested at 2.9. AddForce works properly.

#

I moved the big platform you see to 1.9 y axis and turned off the smaller ground. And...AddForce is working properly.

#

Added a new platformer with 1.9 y axis. Stops working again. Here's hitbox for further details.

vapid crane
#

anyone here have any experience with using articulation bodies? I am finding the spherical joint to be a bit wonky. For instance setting the target angle for two drives to be 90 completely breaks the body. Is there something I'm missing or am I going about this the wrong way?

#

this is the set up

#

decreasing the force limit doesn't fix it either, just forces the body to rotate forever

tender gulch
dense veldt
tender gulch
green ridge
#

hi everyone

dense veldt
green ridge
#

do you guy use skeletal animation often? Skeletal animation just deforms the sprite, not actually change the transform component so when the skeletal moves, the correspondence collider won't move with them. And I can't not find any way to update the box collider. So I think you can't use skeletal with collider and rigid body. Is that right or are there any way to fix it?

dense veldt
#

Only does this at y axis 1.9

#

However, the character is still considered "grounded" so this is very odd.

tender gulch
dense veldt
#

By OnCollisionEnter

#

Using tag

#

Feels like a bug cause it's entirely using the physics engine

#

Actually...I think it might be the custom gravity script Im using

steel sorrel
dense veldt
#

Happening in FixedUpdate

steel sorrel
#

did you forget to enable auto-Physics by amy chance?

cuz THAT, paired with the option of disabled auto-sync transforms will indeed cause the problem you are describing

green ridge
green ridge
tender gulch
steel sorrel
dense veldt
#

And yep bug is gone

green ridge
steel sorrel
#

all colliders static or dynamic follow the Gameonject they are conteined in ... static ones just get re-built at the physic step

arctic plank
#

hello, im trying to build billiard game the first picture is refrence of the aim, but second which is mine seems like my sphere cast dosent work as i expected do any one have an idea how to fix this

or how to achive the first picture

timid dove
arctic plank
#

void UpdateGuidelines()
{
Vector3 dragDirection = (dragEnd - dragStart).normalized;
float dragDistance = Mathf.Clamp(Vector3.Distance(dragStart, dragEnd), 0, maxPower);
currentPower = dragDistance;

    Ray ray = new Ray(transform.position, dragDirection);
    RaycastHit hit;

    if (Physics.SphereCast(ray, sphereRadius, out hit, dragDistance))
    {
        Vector3 adjustedHitPoint = hit.point - dragDirection * sphereRadius;

        originalGuideline.SetPosition(0, new Vector3(transform.position.x, transform.position.y, 0));
        originalGuideline.SetPosition(1, adjustedHitPoint);
    }
    else if (Physics.Raycast(ray, out hit, dragDistance))
    {
        originalGuideline.SetPosition(0, new Vector3(transform.position.x, transform.position.y, 0)); 
        originalGuideline.SetPosition(1, new Vector3(hit.point.x, hit.point.y, 0) + dragDirection * originalOffset);
    }
    else
    {
        Vector3 targetPoint = transform.position + dragDirection * (dragDistance + originalOffset);

        originalGuideline.SetPosition(0, new Vector3(transform.position.x, transform.position.y, 0));
        originalGuideline.SetPosition(1, new Vector3(targetPoint.x, targetPoint.y, 0));
    }

    originalGuideline.enabled = true;

    
    if (endpointObject == null)
    {
        endpointObject = Instantiate(endpointPrefab);
    }

   
    endpointObject.transform.position = new Vector3(originalGuideline.GetPosition(1).x, originalGuideline.GetPosition(1).y, 0);
}

do you see any problem here

flint portalBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

timid dove
#

Anyway it'd come down to whatever endpointObject is I guess

#

also yes

#

you wouldn;t want to draw it at the raycast hit point

#

endpointObject.transform.position = new Vector3(originalGuideline.GetPosition(1).x, originalGuideline.GetPosition(1).y, 0);

#

that doesn't make sense really - I think you want:

Vector3 spherePosition = ray.GetPoint(hit.distance);```
stuck pewter
#

alright so i have a car made with wheelcolliders

#

but it wont work properly

#

it just bounces whenever it moves

#

this is a video of the issue

#

(when holding forwards)

#

currently losing my mind

timid dove
stuck pewter
#

not really sure what to provide

#

theres only one script controlling things

timid dove
#

the code that moves the car would be a good start

timid dove
stuck pewter
#

was originally using a tutorial and followed it to a T

timid dove
#

code seems fine

stuck pewter
#

yeah i figured the code wouldnt be too bork

timid dove
#

something is wrong with the scene setup then

stuck pewter
#

if theres anything specific u wanna see to help lmk

timid dove
#

show how the scene is set up

#

i.e. - what does the car hierarchy look like? What components are on each object and with what settings

stuck pewter
#

this is the car currently

#

the wheels are contained as in the mesh they were rotated in blender so it fucked w the rotating of the wheels in unity

#

so i just centred a parent on them and rotated the wheel mesh itself

timid dove
#

What components are on each object

stuck pewter
#

the colliders are on the collider empty game objects under wheelcolliders

timid dove
#

what about the Wheel.001 object

#

etc

#

what's on those

stuck pewter
#

all the wheels are just mesh renderers

#

the FR/FL/BR/BL are just empty go's

#

nothing on those

timid dove
#

basically I'm trying to see if you didn't accidentally include rigidbodies/colliders anywhere they shouldn't be

stuck pewter
#

yeah that makes sense

#

the root object has a box collider for the car

#

without it the car just kinda falls apart

#

box collider isnt contacting the wheels

#

thats about it when it comes to the car

timid dove
#

if you reduce the acceleration does it still hapen?

stuck pewter
#

yeah

#

reduced damping too

timid dove
#

(btw I recommend turning on interpolation for the car)

stuck pewter
#

alright

#

i move forward then it starts shaking p much

timid dove
#

anything on the object called Car?

stuck pewter
#

just rendering

timid dove
#

Just a MeshRenderer?

stuck pewter
#

ya

#

basically i got a single box collider on the root object to give the car collision and to make sure it doesnt just start going crazy when it hits the ground

timid dove
#

not really sure - seems to check out to me

stuck pewter
#

yeah thats what im sayin too

#

weird issue

#

fucks sake i figured it out 😭

#

forward stiffness too high

#

sucks for me tho as i want tyres to actually stick rather than slide

timid dove
#

vehicle physics are tricky

stuck pewter
#

yeah its real tough

#

ah well, ill figure it out

#

thanks for your patience 😭

stuck bay
#

can anyone help with simple player movement

steel sorrel
#

cuz if u're lucky enough to do something like binding of isaac, it's just about doing an addition to the transform position and clamping the max distance from the center of the world origin 👍

coral mango
#

Is there any way to pause cloth and then re-enable it without a massive frame spike?

#

Or enable it async somehow?

plain pebble
#

Hi

#

I have a tennis court like this in unity

#

I want to capture coordinates of intersection points from the court like this

#

but unity just tells me the asset's position

timid dove
cobalt magnet
#

Okay, I have a weird bug I don't know how to fix.

I just started making a map out of mesh colliders with ProBuilder, but for some reason my bullets now arent always sending collision callbacks upon hitting the wall. It works fine with a normal BoxCollider or convex shapes, but not with a concave MeshCollider.

Here's a video, if it helps. The BoxCollider is on the bottom, and the MeshCollider is the other one. I have some debugs in the bottom for when I'm getting callbacks, but I did forget to add the convex mesh test in the video (but it's the same as the BoxCollider).

Thanks in advance! (I also have some other problems with meshes, but I want to fix this first)

#

I can take pictures of the inspector if anyone wants me to

#

and just another observation, but it seems to not be hitting my player always. It does work perfectly on enemies, though, which have identical collision setups, so I don't think it's related.

wicked phoenix
#

Is there a way to call OnCollisionEnter without actually applying a force to the collided object?

Say I have a rigidbody projectile. I want to call OnCollisionEnter so that I can get contact point data, but I don't want the hit object to be pushed. Is there a way to zero out that impact force?

cobalt magnet
#

or i guess then youd still need it to be triggered, tho

#

maybe you could set it to trigger but manually get the contact point by finding where they overlap?

#

im not sure what this is gonna be used for

wicked phoenix
timid dove
wicked phoenix
timid dove
cobalt magnet
#

Actually, yeah. You should be able to raycast the object, and to go to the point on the surface that you contacted it, just use Physics.ComputePenetration

#

(unless using thin objects/fast projectiles bc it'll bug out)

#

You'd just have to disable the rigidbody or make it a trigger

cursive sparrow
#

Hi, I have some questions about the gradient of a point in a height map (or the slope of a point in relation to it's neighbors height).
This is the formula to calculate the slope:

float dx = heightmap[x + 1, y] - height[x, y];
float dy = heightmap[x, y + 1] - height[x, y];

Then to get the steepness you would use the pythagorean theorem.
The thing is: some formulas for the slope I've seen divide dx and dy by 2 and some even use Acos instead of the pythagorean theorem to get the steepness.
I'm confused to when to use what. Any help?

#

(there is also the x - 1 and y - 1 calculation for the slope)

timid dove
#

although a different dy and dx than in your code

#

more like dy / gridunitsize and dx / gridunitsize

#

to get the slope on each axis

cursive sparrow
#

Nope. The slope of a function yes, but the gradient of each point uses "central differencing" on each point.

#

Need calculate the slope by differentiate the height of each point, then get the steepness

#

The slope in this case is the difference in height

#

Which some times I've seen people dividing it by 2

#

This is useful (in my case) to simulate rivers

#

So the river flows by choosing the steepiest neighbor

wicked phoenix
#

what two methods?

timid dove
#

Ok we're in over my math knowledge here then so I'll bow out 🙇‍♂️

cursive sparrow
#

Haha, it's ok

#

Btw, I got the answer. It's because I was using a different formular (finite difference), it doesn't need to divide by two.

#

The central differencing needs to calculate the distance between points and uses a slightly different way of getting the slope

#

I would want to show the formula and what is going on to you, but I don't know how to write it on discord

#

So I'll just say

#

"Trust me bro"

reef lily
#

Hey guys is there some underlying magic with trigger and collider events?
I'm trying to scale a trigger area, and at some point it reaches a collider. But no trigger event is generated. Is that by design?

reef lily
#

ok that just doesn't work with static elements

coral mango
#

Is there a way to get all joints connected TO a specific rigidbody?

wind meadow
#

question does having one instance of the platform effector completely override the collision matrix?

hushed salmon
#

why do 2 spring joints when connected to an object sometimes make the object flip the wrong way

#

its supposed to hang like this

daring ridge
#

I need help with some collider situation I have. In words: It seems like the layer of the collider is ignored/mixed up when inheritance is involved.
In the following image, I'm trying to explain my problem:
Top left: This is my structure. The Crate sprite is attached to "Crate (2)". "Main" has a Box Collider 2D, on the layer "Player Ignored Collider" (top right image). "Smaller" has another Box Collider 2D, but is on the layer "Default" (top middle image). The "Table" (bottom right image) has a Box Collider 2D and is on the "Player Collider" layer.
Based on the collision matrix, I would expect my "Crate (2)" to fall partly through the table, but as you can see on the left image (which is the state reached once the game plays), it gets stopped by the collider on "Main" even if the matrix says it shouldn't.

Anyone can enlighten me?

timid dove
robust kestrel
#

Hi everyone, I have a question regarding bcollider and raycasts for object detection and its performance. I plan to attach a box collider to an enemy and anything that touched it will be detected, similarly, I also want to try having a raycast shoot out every fixed frame, to detect collisions. I wonder which approach is more performant, especially if I could have 100s of enemies in a single scene?

timid dove
robust kestrel
# timid dove Which approach out of what options? You only listed one.

Sorry for not being specific. Option one is using a box collider attached to the enemy gameobject, and the enemy will move around while the box collider detects for collisions. Option two is no box collider, but instead the enemy has a raycast that ping pongs from a minimum and maximum angle at every fixed frame and detects collisions that way

daring ridge
timid dove
#

Also if the enemy has no collider how will collisions with it be detected from other objects?

robust kestrel
robust kestrel
timid dove
robust kestrel
timid dove
robust kestrel
# timid dove Trigger colliders for LOS (at least the first phase of it) are almost certainly ...

True, you're not creating a raycast each frame, the collider is already loaded. However I have to solve the issue of scaling it so that it can detect objects far away, and detecting an object that is behind another object.. maybe a simple boolean check to see if the layer I collided with, let's say "Wall", was triggered before the "Player" layer, indicating that the player is behind the wall and the collider shouldn't do anything?

timid dove
#

To make sure they're not behind obstacles

robust kestrel
daring ridge
#

What's the standard approach to have an object being controlled by the player that:
1- Is not subject to gravity (while most objects are)
2- Can't go through walls
3- Can push other objects, but not get them through walls

#

I'm thinking of a way with both a normal collider, and one a bit smaller that's a trigger collider that would stop the input motion in that direction, but that seems like a lot of trouble, and a bad solution.

timid dove
#

Nothing special

daring ridge
#

And you move it with a script that does what? Set position, and you let the engine kick you out of the walls? I though that was a bad idea.

timid dove
#

Sets velocity

#

Or adds forces

#

Never set the position explicitly that's asking for trouble

daring ridge
#

I was thinking of set velocity, but I guess I set my weight to something very heavy too?

daring ridge
timid dove
#

Basically what you described is bog standard normal physics behavior

daring ridge
#

Well, if I set velocity, but I'm not super heavy, everything will stop me, no?
In my case it's moving a crane, so I don't want basic objects to stop it.

timid dove
#

But if you want your object to be massive, make it massive

#

You can set the mass to whatever you wish

daring ridge
#

Alright. I'll try that! Thanks again 🙂

cobalt magnet
#

ive been trying to fix it, but im completely stuck (and im not used to 3d and meshes)

timid dove
#

Continuous detection mode for the wall won't help at all since the wall isn't moving

cobalt magnet
#

the bullets dont have rigidbodies, but even so, it works on the convex shpaes

cobalt magnet
#

thats performance intensive and it works without them

timid dove
#

If you want the best collision detection the moving things need rigidbodies

#

The stationary things don't need them

#

If your bullets don't have rigidbodies how are they moving?

cobalt magnet
#

transform.position

timid dove
#

Your code is almost certainly more performance intensive than letting a rigidbody move them

cobalt magnet
#

but it hasnt been a problem up until now

#

ill try it tho one sec

timid dove
#

When you do that make sure they're moving via RB velocity and not via just setting the position in a script

#

BTW without a dynamic body involved you can't get OnCollisionEnter anyway

#

So I assume you're using a trigger?

cobalt magnet
#

yep

#

the bullet is the trigger

timid dove
#

Triggers don't really benefit from continuous collision detection at all

#

They're pretty much always in discrete mode

#

At that rate you'll probably have to supplement this with SphereCasts

cobalt magnet
#

oh crap

#

ive been trying to make it work on the enemies bullets instead of the players lol

#

ill be a bit longer then

#

ok yeah its still bugging

#

so are you thinking i just do my own collision detection?

timid dove
#

I think the best approach is:

  • Make the walls have only a non-trigger collider
  • Give the bullets dynamic Rigidbodies with continous collision detection mode (not speculative, that's for rotating oblong objects). They should have gravity and drag disabled and just be given a velocity once at the moment they spawn.
  • Bullets should not have Update, LateUpdate, or FixedUpdate functions
  • Handle the collision with OnCollisionEnter
#

this will give you the most robust collisions and best performance

cobalt magnet
#

ok ill try this out

timid dove
#

If you have a performance issue with this you can try using the job system and do your own collision detection with IParallelTransformFor and IRaycastCommand

#

failing that, ECS.

cobalt magnet
#

okay, that does seem to work, but i think ill have to redo my collision systems since it pushes the player again

#

i had wanted to keep it so that all bullets used the same layer, but i think they'll have different layers but the same tag and it should be fine

#

then i can set it so they dont collide with their team

timid dove
cobalt magnet
#

they still collide with the player, though

#

they just dont push it then