#⚛️┃physics

1 messages · Page 3 of 1

sacred vault
#

here is the code of the missile

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

public class Bullet : MonoBehaviour
{
    // Start is called before the first frame update
    public BoxCollider boxCollider;
    public GameObject explosionParticle;


    void update()
    {
        
    }
    private void OnTriggerEnter(Collider other)
    {
        if(!other.CompareTag(tag))
        {
            Debug.Log("collidé");
            Explode();
        }
        
    }

    void Explode()
    {
        GameObject explosion = Instantiate(explosionParticle, gameObject.transform.position, Quaternion.identity);
        explosion.GetComponent<ParticleSystem>().Play();
        Destroy(gameObject);
        Destroy(explosion,2);
        
    }
}
#

the velocity is set to 100f

#

here is the missile

#

here is the collision parameters of the missile

#

what is wrong with my setup ?

timid dove
#

you probably just have an offset on your particle system prefab AND/OR the missile prefab

#

make sure your tool handle position is set to pivot in the editor

sacred vault
#

as you can see, 3 stages of the process, the particule system is triggered on the cross, and no, there is no offset in my prefab

#

when I gently drop the missile on the ground, the particle system is at the right place

timid dove
#

but

#

is your tool handle position set to Pivot?

#

or Center?

#

Same for your particle system screenshots

#

Also in the prefab itself, show the inspector of the root object? Is the position there 0, 0, 0? Or something else?

sacred vault
timid dove
#

your inspector is in debug mode btw

sacred vault
#

yes ?

timid dove
#

ok so - you're using a trigger collider

#

and i assume your missile is moving quite fast?

sacred vault
#

yup

timid dove
#

This could just be some run of the mill tunnelling

sacred vault
#

yup 100f of velocity

timid dove
#

maybe instead of using OnTriggerEnter you use a non-trigger collider and OnCollisionEnter

#

another alternative is to do your own BoxCasting in FixedUpdate

sacred vault
#

I'm going to try OnCollisionEnter

#

same issue, it seems like this is the engine being not fast enough

#

I'm probably going to raycast where the missile is going to land and play the particle system at this raycasted point

gilded blaze
#

at any speeds where the collider moves more than its own size in one frame, you will get tunnelling. You can either use continuous collision detection mode on your rigidbody (can be expensive if there's a lot of them), or you can manually raycast ahead or after your object by script, and find stuff it might have missed along the way

#

raycasting is probably cheaper if you use scheduled raycasts instead of the normal ones

sacred vault
#

continuous collision doesn't change anything

gilded blaze
#

yeah, I haven't had too much luck with that either in the past

#

it's supposed to be more or less the same as raycasting behind your object to find collisions you would have missed (IINM), but I've never seen it work very well

#

in my experience, it's much more reliable to do the raycasting and do your own collision handling from any hits when they happen

sacred vault
#

it's working much better, thanks you guys 😉

quiet dirge
#

I got Dynamic Bones put into this rope on my model, and when I use Play in Unity, it moves as I slightly jiggle my model. When I export and load up the program to see my model move, the rope doesn't move at all.

#

Anyone have any clue?

copper inlet
#

Is there any way to make DOTS Unity Physics objects to collide with normal colliders? Been trying to figure out a way, but there seems to be none.

carmine basin
copper inlet
#

Yeah, figured out, but wanted to be sure. Thanks.

Though it's pretty sad. Would've really liked to use those super performant physics objects with how I'm already familiar with using Unity, aka not dots.

supple sparrow
strange lark
#

What are some good ways to decollide if an actor is stuck between objects?

#

Some examples, actor in green

#

Using only the surface normal will not work in this case, since the actor will be pushed back into the other object

woeful cave
#

uhhhhhhhhhhhh delete the actor

supple sparrow
#

Uhm, aren't they because a huge resolution of vertices ?

#

All unconstrained, appearing as a big black shape ?

#

Maybe

#

so, your skirt could be too much high poly ?

copper inlet
#

The higher poly your mesh is, the more performance it takes, especially with cloth physics.

#

You don't have to edit it, if you can run it, but if you're facing performance problems you probably should edit it lol

quiet dirge
#

The physics on my accessory doesn't work when I load up my model in VSeeFace, any clue why?

#

they do work when i test them in Unity with the play scene tho

wispy patrol
#

How do I detect that the car is flipped? Do I check the rotation, and if it's on it's side or back for a certain amount of time, then what should I do?

carmine basin
supple sparrow
# wispy patrol How do I detect that the car is flipped? Do I check the rotation, and if it's on...

Many ways to check if it is flipped. I would have used the Dot product (Vector3.Dot()) between the world up and the transform up. But yes you could check rotation, this could be enough. Or even transform.up.y < 0f might be enough (?). I'll let you try what works best for you.
As for "then what should I do", you're actually asking the same question you quote from our previous conversation, so I guess my answer is the same 😉 But again, that's one naive way of doing it as a first try and see if it works for you, more involved way could include Raycasts and other rules to fulfill, as many as need depending on your game 😛

#

I'd say yes too much for a cloth component. That's your high quality asset I assume ? I'm not an artist but I would assume that the cloth component would be put on a way simpler mesh (like only a dozen vertices) that drives joints for a skinned mesh renderer, but maybe I'm wrong 🤷‍♂️

#

My next step - as a non-artist needing to catch up - would be to just watch a youtube tutorial, I'm even ready to bet you can find one with a skirt cloth specifically 🙂

#

and see which mesh resolution they go for

noble niche
#

can someone tell me how can make collider lower Such as The green line drawn in the picture

woeful cave
#

I imagine you just tweak those offset values?

jovial wraith
crude grotto
#

Do you guys have any advise how I can make the force applied to the arm rotate the body as the force travels along the character joints? I thought this should be happening by default😅

#

the joints break force is unlimited and at higher forces, the arm will just start to glitch rather than rotating the connected rigidbodies. I suppose in reality until a very high force, the body would rotate. Unless its like a .50 cal to immediately tear off the arm

quiet dirge
#

I was told I need to add colliders in order for my gourd's ropes to actually move in VSeeFace, despite them moving in uNity's play scene. What kind of collider do i add, a Dynamic Bone one? I assume I had it to character model,b ut do i add it to the Root, or the place where my gourd is attached, which is the Spine?

quiet dirge
#

anyone?

quiet dirge
#

bump

supple sparrow
crude grotto
supple sparrow
#

Ok you said yes but it's the opposite, pretty close.

#

Maybe gravity is too much compared to the force you apply

#

Try applying greater force on the arm, see what happens ?

crude grotto
#

When I do that, the arms joints will start to glitch (jump around the space randomly) before there’s significant impact on the body

supple sparrow
#

Oh yeah that's what you wrote, I immediately ignored that sentence after reading it xD

crude grotto
#

Do you know if that force-transition to the next joints is done utilizing the colliders?

supple sparrow
#

I never tried multiple joint articulated bodies

#

maybe apply the force to the closest point of the body, to circumvent this force propagation problem entirely 😛

#

But anyway at first I'd try to stabilize the simulation at rest. It's falling down to gravity in a strange way.

supple sparrow
supple sparrow
supple sparrow
#

yeah limbs look good but the body is not fluid

crude grotto
#

That’s just because I used some Unity setting to slow it down so I can see better how the rbs are responding to the force while i was /am trying to find a way to make the body rotate with the force 🙂

supple sparrow
#

Using Configurable Joints ? with pretty much default settings or heavily tweaked ?

#

And how do you apply the perturbing force

west whale
#

Hello, I started working on a vr project and I want to make fluids interact (for example pouring a liquid in another and make them change color) any ideas how I could achieve that?

raven leaf
#

apparently it cilps through the floor

#

Idk if i can talk about rigidbodies here but

#

While i want it to fall i don't want it to clip

wooden parcel
#

i have a really basic question. I have a 2d animation from a spritesheet and i'm trying to make polygon colliders for hitboxes on different frames. I created one polygon collider and it allowed me to edit the frames that it is active in the animation editor, but when I add a second polygon collider they appear to be treated as the same thing? I can't edit just one collider at a time, it selects both, and i can't access just one collider's isenabled property. is this something i'm doing wrong or is unity not able to treat two identical components as different?

wind meadow
#

for physics2D.overlapcollider, is there a way to get the objects themselves that came in contact with the overlapcollider?

#

similiar to Physics2D.overlapcircle

timid dove
wind meadow
#

ah ok it's just that on the doc it said it returned an int

#

so i was worried that it wouldn't give back the results array passed in

timid dove
wind meadow
#

yeah just being doubly sure

timid dove
#

It tells you how many things it wrote to the array

#

That's what the int means

wind meadow
#

gotchu

#

that said i guess we can't pass in a list or some datatype that can take in an arbitrary number

timid dove
#

Read the docs

#

There's a list version

wind meadow
#

ah then apologies

clear ermine
#

so i'm using wheel colliders (fatal last words) and for some reason when I lift off the accelerator and start coasting, my car appears like it's slamming on the brakes.
i've got it printing the motor and brake torques and they are both 0 while the car is locking its wheels skidding to a stop.
has anyone got an idea of a parameter or setting that could by causing this.
the car i'm using is very small and light if that could be causing it (trying to code a small RC car)

quiet dirge
#

Where would I normally put colliders? Right up against bones, over the top of bones, or what?

carmine basin
fluid galleon
#

Hello there. I'm struggling around with a certain problem around 2D physics. I'm trying to make vertical-scrolling shot'em up game where player can move around ship, fire at enemies coming to waves, etc. (something like Hybris, Dove, Tyrian 2000, etc.).

In my implmentation, player and enemy aircraft are rigidbodies (2D) as I want them to have semi-realistic collisions if they happen. There is one thing however I cannot figure out how to do. As aircraft is physics based, I'm struggling to make everything to follow scrolling camera. I cannot simply parent aircraft to camera, because physics wont work properly (tried it - parenting makes no effect). Tried to use FixedJoint2D to glue aircraft to camera, and while they now travel with camera, I cannot move ship at all and it looks like its correct behaviour for the joint.

I cannot simply manipulate transforms (because they are rigidbodies), and I cannot use RigidBody2D::MovePosition as it resets ships velocity for next tick.

Also tried to make ships static and only scroll background in opposite direction (instead of moving camera upwards, background moves downwards), but unfortunately this causes massive fps drop, as my background is tilemap and moving it makes unity to recreate & recalculate all coliders within it (300fps down to ~50-60). I think it could mess with culling as well so I ditched the idea.

Is there any way to connect one rigidbody to camera, yet still allowing them to move relative to camera as normal?

quiet dirge
#

Good luck getting help in here, people don't even help with simple things sometimes lmao

carmine basin
carmine basin
carmine basin
#

If you want bones of something to collide with something else, then you attach them to the bones

#

Attaching the collider to the mesh won't do anything when the mesh is deformed

carmine basin
fluid galleon
#

Actually I just checked it and now it does for some reason, I think I probably messed up something with programatic parent assignment

carmine basin
#

hm. If you're resetting the velocity of all the ships and such every frame, you could try adding the camera's velocity on top. Like, at whatever speed you're moving the camera, add that onto the velocity of the ships and stuff

#

so it'd be something like

ship.velocity = moveVelocity + (Vector2.up * cameraSpeed);
#

just as a rough thing

fluid galleon
#

I'm not resetting velocity, I'm using physic forces to move ships so I cannot touch .velocity at all unfortunately

carmine basin
#

ahh, I see

fluid galleon
#

However I see now that making ship a child of camera actually makes it travel with camera, I probably messed up somehing earlier on

carmine basin
#

You could've just mucked up parenting somehow

#

it happens, sometimes we just don't parent something when we think we did

fluid galleon
#

Now I did it simply on scene, by hand and when I was testing I was using transform.SetParent from the code, perhaps thats difference, I'll check it out

#

Yup it works now, I think I might have overlooked something previous time I tried. Its actually a little bit more complicated, I've used the term "parent to camera" as simplification but in reality I've special object called GameRail that "travels upwards" and Camera is child of that object 🙂 Thanks for help @carmine basin 🙂

mystic walrus
#

i have a issue with my game were the player is only able to walk through the main door that takes you to level 2 while he can still move on the ground and walk just fine

carmine basin
#

Check your collision matrix, see if the layer the door is on collides with the layer your character is on

mystic walrus
#

ok

stuck bay
solemn meadow
#

Hi guys, i am having a problem with this script to predict the movement a celestial body will make based on its starting velocity and distance to the sun. Im running the CalculatePoints function in void FixedUpdate(), and the tmpBodies array is an array of TmpBody classes, which contain a mass, position and velocity. This array is just a copy of the actual celestial bodies in game, and also gets updated constantly in fixedupdate(). As you can see in the video, it doesnt work haha. The sliders are updating the starting velocity of the body, but nothing happens to the path, which should change to go around the sun.

#

Just taking a look at this would make me so so glad because its for a school project and I dont have much time left

timid dove
#

also when you share code please follow the guidelines at the bottom of #854851968446365696 . It's very hard for me to copy/paste and/or reference specific parts of your code since it's not text and there's no line numbers.

solemn meadow
#

I'll keep the guidelines in mind next time :)

raven leaf
#

So i wanted to make objects that can be pushed by the player ( a capsule) as they walk in the game, i used books (for a specific level test) and they have a rigid body but they are too small the player walks over them

#

i did then make the collised bigger but now it collides with the other books / ground and looks like if it's floating

#

am i using the wrong way ?

solemn meadow
raven leaf
#

the problem is in the books collider as if they flip to the other side they will look like theye are floating

timid dove
timid dove
raven leaf
#

i want the player to move the books when he walks

timid dove
#

Can you answer my first question?

timid dove
#

With what collider?

#

Can you show the player inspector and the code you use to move it?

raven leaf
#

i used an asset from the unity assets store

timid dove
#

Ok well... Maybe that script has a "step over small obstacles" feature

raven leaf
#

using System.Collections.Generic;
using UnityEngine;

public class FirstPersonMovement : MonoBehaviour
{
    public float speed = 5;

    [Header("Running")]
    public bool canRun = true;
    public bool IsRunning { get; private set; }
    public float runSpeed = 9;
    public KeyCode runningKey = KeyCode.LeftShift;

    Rigidbody _rigidbody;
    /// <summary> Functions to override movement speed. Will use the last added override. </summary>
    public List<System.Func<float>> speedOverrides = new List<System.Func<float>>();



    void Awake()
    {
        // Get the rigidbody on this.
        _rigidbody = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
        // Update IsRunning from input.
        IsRunning = canRun && Input.GetKey(runningKey);

        // Get targetMovingSpeed.
        float targetMovingSpeed = IsRunning ? runSpeed : speed;
        if (speedOverrides.Count > 0)
        {
            targetMovingSpeed = speedOverrides[speedOverrides.Count - 1]();
        }

        // Get targetVelocity from input.
        Vector2 targetVelocity =new Vector2( Input.GetAxis("Horizontal") * targetMovingSpeed, Input.GetAxis("Vertical") * targetMovingSpeed);

        // Apply movement.
        _rigidbody.velocity = transform.rotation * new Vector3(targetVelocity.x, _rigidbody.velocity.y, targetVelocity.y);
    }
}
mystic walrus
lone quartz
#

Is there a way to debug draw an CapsulecastCommand ?

timid dove
lone quartz
#

Thank you

wide pendant
#

is it better to use box collider for the head and circle collider for the body and legs? (2d)

timid dove
wide pendant
#

in that case

#

is it bad to have 3 colliders

timid dove
#

no

unique cave
timid dove
#

Yes if you're using a binary computer it can't count to 3, so it will explode on the third one.

potent notch
#

wondering if anyone that has used nvidia flex would mind giving me an example script on how to get triangle meshes working, or something like that? (i know the manual does say how to do it, but i just cannot get it to work properly, sorry lol)

copper inlet
#

Flex working also kind of depends on the Unity version of which you're using. Some newer ones don't support everything.

potent notch
copper inlet
#

And if you're using my Flex rep, some of the things in there might be outdated and won't work with every part of the docs

#

Ah.

#

Can't help then, I guess. But I wish you luck lol

potent notch
#

thanks lol

drifting flare
#

Can anybody help me with Physics.Overlap or Physics.ComputePenetration

hardy gazelle
#

As you can see I don't have animations just for this character - just the standard mixamo stuff for testing and i wanted to know if i can seperate the arm colliders to only affect arms and thigh colliders to only affect the bottom of the kimono. Also wanted to ask if there is a way so the sleeves dont roll back and always stay down (second vid)

high dagger
#

I want to connect a clothing model to the skeletal structure of the character in-game. Normally, I make things like sword and hat directly as child object of the relevant bone, but when it comes to clothes, it concerns more than one bone, there is no proper resource on the internet, can you help?

timid dove
sharp umbra
#

I graphed how long a cube took to stop on a flat surface. https://docs.google.com/spreadsheets/d/1s6b4xnqbo-ORcMikkucjH510hzQvtfMaeY4c8wowCAg/edit?usp=sharing

In an ideal world this would look like a perfect staircase where each step is the height of your fixed update interval, but as you can see it's not. I believe this is because physics is on a separate thread and jobs don't get done perfectly in sync.

Moral is the story, is that even in ideal controlled physics situations, your expected result could be a frame off.

timid dove
sly cliff
#

Am I going to have to code like a whole physics engine thing if I am aiming to make a vr game like bonelabs/blades and sorcery?

timid dove
drowsy parcel
#

why my car box collider looks like this?

#

oh wait

#

im dumb

#

why when i start the game car falls through that red thing

#

why when my wheel colliders were so giant

#

there is 0.011 radius

#

and its still big

timid dove
drowsy parcel
#

i have a problem

#

when i start the game

#

my back left wheel collider

#

just

#

flies away

#

UpdateWheel(FrontLeft, FrontLeftT);
UpdateWheel(FrontRight, FrontRightT);
UpdateWheel(BackRight, BackRightT);
UpdateWheel(BackLeft, BackLeftT);

#

i figured out that it does this because of the script

#

but why

#

i had this script before

#

and it worked

potent notch
#

oh and this was my c# replication btw: ```cs
for (int i = 0; i < Container.SlotsUsed; i++)
{
int ContactIndex = Container.SBuf.ContactIndices.data[i];
uint Count = Container.SBuf.ContactCounts.data[ContactIndex];

        for (uint c = 0; c < Count; c++)
        {
            Vector4 Velocity = Container.SBuf.ContactVelocities.data[ContactIndex * 6 + c];

            int ContactShapeId = (int)Velocity.w;

            if (ContactShapeId == ShapeIndex)
            {
                Debug.Log("Collision!");
            }
            else
            {
                Debug.Log(ContactShapeId);
            }
        }
    }
potent notch
#

ok turns out i wasnt grabbing the data properly, whoops lol

drowsy parcel
#

Could someone help me with drift physics, just some tips please

potent notch
broken rover
#

Hey there! I'm incredibly new to Unity so I have a very beginner problem that I'm dealing with that I hope you could help me with...

So basically this player capsule that was included in the Third Person Starter Asset Package from Unity won't function properly I think? The collider seems to match with the capsule but for some reason it goes through the platform and interacts with the platform as it's using the top mesh for reference. How do I fix this?

broken rover
#

I have no idea. I think it came like this

timid dove
#

I don't think so

broken rover
#

Okay, so how do I remove one of them?

timid dove
#

It works properly out of the box

timid dove
#

From the asset

#

Redownload the starter asset

#

Delete and redownload

broken rover
#

Okay, thank you!

#

I think I managed to undo my changes without having to reinstall everything! phew

#

It works now :)

limpid condor
#

Hello, guys! I am experiencing a strange problem, so the problem is that when I play the game the rover's tires fly away. I've added a wheel colliders to all wheels and I've made a rigidbody to the whole model. Please be easy on me 😄 I started 2 days ago

shrewd umbra
#

hey guys, i already sent this message in general but i think this is a more appropriate channel for this, does anyone know a good way of making a suspension system for a dirtbike? im talking about 2d and i have these parts for the bike

#

the whole bike looks like this

#

And i wanna make it similar to this game

unique cave
shrewd umbra
#

yeah im trying that rn

#

but i have a problem

shrewd umbra
#

but now the suspension at the front doesnt work

#

idk how to explain it

#

i wanna make it so the tube thing is in one place and the bike like goes into it

#

like in the video

shrewd umbra
#

i've got this now

#

but i need the tube to stay still

#

dont know how to do that

unique cave
shrewd umbra
#

no i use a sprint joint

#

for both

unique cave
#

Why not?

shrewd umbra
shrewd umbra
#

and i find the spring better

#

i need this tube to stay in rotation with the bike frame but not be attached to it

#

if you get what i mean

#

so the front of the bike can actually go down

unique cave
shrewd umbra
#

i dont either tbh

unique cave
#

That ”tube” doesnt affect the game in any way other than the visuals, you could just code it to stay in place

shrewd umbra
#

yeah but there has to be a way to make it stay in one place through the editor

unique cave
#

Just code it

shrewd umbra
#

i've done this

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

public class Stay : MonoBehaviour
{
    public Transform bike;

    void FixedUpdate()
    {
        gameObject.transform.rotation = bike.rotation;
    }
}
#

but now it wobbles like a jelly

#

wait no

#

it still doesnt work

#

i had the rotation z freezed

unique cave
#

For example: 1) make the tube origin be at the wheel attatchment point 2) set tubeTransform.position = wheel.position every LateUpdate (so that the wheel side end is on the correct position) 3) set tubeTransform.up = target.position - wheel.position where target is a position on the bike body you want to make the tube face towards (you can make an empty object somewhere here ⬇️ be parent of the bike tar works as the target)

unique cave
shrewd umbra
#

spring

#

joint

#

for both wheels

shrewd umbra
#

i accidentally freezed the z rotation

#

thats why

unique cave
# shrewd umbra spring

🤦‍♂️ Man, you have been told multiple times to use the wheel joint, its designed specifically for wheels with suspensions and will make it million times easier to get this working

shrewd umbra
#

with the problem that i have here

#

it doesnt matter which joint i use

#

if its spring

#

or wheel

unique cave
#

But to get the wheels working, you must use wheel joint

shrewd umbra
#

the wheel is working

#

the suspension

#

but not the connection

#

between the tube and bike

unique cave
#

So what it looks now?

shrewd umbra
#

gimme a sec

#

so the bike_suspension aka the tube is connected to the wheel at the bottom with a hinge joint, i also connected it now to the bike_frame with a fixed joint so that it doesnt have any suspension and now and acts as a part of the frame

#

it now looks like this

#

but i need it to look something like this

#

i dont know what to do lol

unique cave
shrewd umbra
#

i dont know how to make it look something like that

unique cave
#

By using wheel joint?

shrewd umbra
#

alright

#

fine

#

lets use a wheel joint

#

how do i attach it

#

from the wheel to the frame?

unique cave
shrewd umbra
unique cave
shrewd umbra
#

wdym

#

ye it wobbles like a jelly

#

but its not supposed to

#

its supposed to just go down

#

and up

#

but it also goes from side to side

unique cave
shrewd umbra
#

wdym

#

the tube is attached to the wheel

#

so that the wheel can spin

#

with a hinge joint here

#

and the wheel is attached to the frame of the bike with a wheel joint

#

but the tube isnt attached to anything now execpt the wheel

#

thats why it spins around

unique cave
shrewd umbra
#

not even the wheel?

unique cave
#

No, you can code the position to stay correct

shrewd umbra
#

alright

#

now it just drops out of the map

#

what next

unique cave
#

Now make sure the wheel joint is working properly

shrewd umbra
#

ill show u

shrewd umbra
#

it wobbles to the side as well

unique cave
#

Afaik the wheel joint suspension should only allow movement along the axis defined by the angle parameter

#

Its really hard to tell from that video. You could make the spring more loose to make it more clear

shrewd umbra
#

alright

#

i just set the angle

#

so its like going up the tube

#

115 degrees

#

ill send a vid

#

i made it loose

unique cave
# shrewd umbra

Why the backwheel seems to work much better? Does it use wheel joint too?

shrewd umbra
#

spring

unique cave
#

Ah

shrewd umbra
#

but i just changed it to wheel now

#

its the same

#

both are wheel

#

i've just realised something

#

ill show u

#

i've had the wheel connected to the frame

#

instead of having the frame connected to the wheel

#

so the anchor moved with the wheel

#

thats why it wobbeled

#

i'll record a quick vid and show you what it looks like now

#

i've disabled the back suspension for this clip

#

to see more clearly

#

it works now

#

but i just need to make the tube stay in place

#

and not fall of the map

#

can u help?

unique cave
shrewd umbra
#

alright

#

thank you

#

i was thinking this

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

public class Suspension : MonoBehaviour
{
    public Transform middleFrontWheel;
    public Transform bikeFrame;

    private void FixedUpdate() 
    {
        gameObject.transform.rotation = bikeFrame.rotation;
        gameObject.transform.position = middleFrontWheel.position;
    }


}
#

the Transform middleFrontWheel is the middle of the wheel

#

just an empty game object

#

and i removed the rigidbody from the tube

unique cave
# shrewd umbra

I still really think the wheel joint should be attatched to the wheel and the connected body should be the frame, that starts mattering when you start using the motor to rotate the wheel. Now that I check your hierarchy closer, I think the wheels shouldnt be child of the body because that will mess up with the physics, the frame and the wheels should be independent objects (hope that was it, and now I will go sleep, ill be back tomorrow)

shrewd umbra
#

okay thx

glacial notch
#

I'm newish to Unity, can the built-in physics support acceleration in collision detection calculations accurately?
as opposed to like using simple arithmetic to += or -= the speed, which makes instant changes to speed values that can result in skipping obstacles that would otherwise be hit if the projected player path was calculated including the acceleration throughout the path (as opposed to at the start/end of the calculation)

#

not sure if that makes sense, lmk if I can clarify

#

or would achieving the above require editing the physics system or making your own from scratch?

bleak umbra
glacial notch
#

so like in the delta between two physics updates, the acceleration/deceleration should not be incremental/discrete, it should be part of the equation, idk if that in math requires like a higher order equation or not but yeah

#

I'm not sure if built-in Unity physics is capable of this

bleak umbra
#

unity physics will check for collisions between the current and last step

#

but it will not take acceleration into account, it will just assume a liner path

glacial notch
#

ah and it's impossible to make it a non-linear path?

#

or like, not practical / Unity's built-in physics doesn't readily support it?

bleak umbra
#

its completey unnecessary for game physics

#

if you need more accuracy, lower the time step

glacial notch
#

I'm trying to make a competitive very fast-paced 2D game, and I'm trying to implement more accuracy instead of just a linear path in collision detection to account for potential inaccuracies present when between two steps much more significant changes in position can happen

glacial notch
bleak umbra
#

whatever fits your definition of accurate enough

glacial notch
#

hmm I see, and this is probably better than changing physics to account for non-linear paths in collision detection?

#

in terms of performance etc

bleak umbra
#

if you make a competitive game, you should probably not use the default simulated physics

glacial notch
#

how come?

#

are there some other problems that come with default physics, if I turn up the physics steps per second?

bleak umbra
#

its not really meant to produce accurate gameplay

glacial notch
#

what are some/any of the more significant compromises it makes that may negatively affect competitive games seeking accuracy?

bleak umbra
#

unity physics are inherently non-deterministic

glacial notch
#

hmm I see

#

are there any popular packages you might happen to know of or anything you suggest for a good replacement, that is deterministic and meant for accurate gameplay? (instead of like writing another physics system from scratch, I assume that's a lot of work) - or any resources that have information on this

bleak umbra
#

its also difficult to tune the game feel when using built in force simulation

#

you havent explained what your game is

#

its impossible to make any suggestion

glacial notch
#

2D platformer like brawlhalla/smash bros but bigger maps & more players, very fast-paced, tile-based

bleak umbra
#

also consider that you are likely overdoing it

#

and actually builtin default physics are plenty accurate for your needs

glacial notch
#

I'm remaking another 2D game that had a very high skill ceiling and was very fast-paced, where many players complained and suffered from shoddy physics etc, so a focal point for me is to make physics here really good if possible - for a reasonable amount of effort

bleak umbra
#

you can try using havok or making a custom simulation

glacial notch
#

custom simulation meaning like from scratch? (probably not too big of a deal for a 2D platformer)

bleak umbra
#

meaning you simulate exactly for the accuracy you need and specific to your game

glacial notch
#

would havok thus count as a tool that allows for custom simulations, or do custom simulations require you to write your own physics math from scratch for collision detection etc?

bleak umbra
#

you can still use the physics API, but you replace stuff thats too imprecise for your taste with a better solution

glacial notch
#

ah I see

bleak umbra
#

havok is just a different physics engine that unity can use (built-in is PhysX)

glacial notch
#

hmm I think before anything I'll check out havok then

#

otherwise with the help of the information you've provided so far I think I'll probably be able to find some pointers for learning to make custom simulations, but on the off-chance you wouldn't happen to know of any learning resources that teach or help with that?

bleak umbra
#

generally nobody does custom physics because its just way too hard to do

glacial notch
#

right, makes sense, I was thinking the same, albeit probably not the craziest deal for 2D platformers

bleak umbra
#

in a 2D game like you describe the typical approach is to not use the builtin sim physics and just implement a kinematic controller for all pawns

#

with custom collision detection and possibly custom de-penetration

glacial notch
#

interesting

bleak umbra
glacial notch
#

I'm thinking to stick with just a rectangular body & hitbox etc for the player characters as in the original game

glacial notch
#

fair enough

#

I'll check out more on kinematic controllers as well, and the reasons for their usage

bleak umbra
#

typically you have multiple rect or spherical hitboxes

#

but that depends on your game design

glacial notch
#

as opposed to a single one for an entire character/entity?

bleak umbra
#

a fighting game typically has a custom box for each attack

glacial notch
#

to match the animations essentially?

bleak umbra
#

typically animations and boxes have little correlation

#

its more about timing than shape

glacial notch
#

yeah I feared that might've been the case, but nonetheless essentially not just a rectangular hitbox for everything

bleak umbra
#

yes, rectangular box

#

its much easier to understand for players

glacial notch
#

oh still rectangular? different dimensions for each attack? otherwise, what is exactly a "custom box"

bleak umbra
#

custom dimensions

glacial notch
#

ah alright

#

I guess boxes inherently are rectangles 😄

#

fair enough

#

and... do kinematic controllers involve a different system to PhysX then?

bleak umbra
#

no

glacial notch
#

unrelated?

bleak umbra
#

kinematic just means that you do not use forces

glacial notch
#

hmm, I think I get what you mean

#

I'll research about kinematic controllers then

bleak umbra
#

built-in forces that is

#

you can still create your own forces

glacial notch
#

hmm

bleak umbra
#

but you dont use AddForce()

glacial notch
#

so PhysX/built-in physics are less involved, you sub out some components for some extra stuff as part of your kinematic controller code/packages

bleak umbra
#

its all still the same physics engine that is being used for figuring out collisions

#

you are just not using the builtin simulation

glacial notch
#

does that not suffer from the deterministic/accurate gameplay problems?

bleak umbra
#

well, ofc it does, if you make shitty inaccurate sim, you have the same problem

#

but you can, in theory, fix all those issues

#

but you need to understand, you arent doing this to fix the inaccuracy

glacial notch
#

I think I get what you mean, it's more of a step-by-step thing where you just target each individual problem and figure out how to get around it, regardless of how that looks like in terms of using built-in API or adding extra stuff, eventually you'll get something working that is accurate/deterministic enough for a fast-paced game

bleak umbra
#

you are doing this to have more control about the specific things your game needs

glacial notch
#

right right

#

alright, things make more sense now

bleak umbra
#

game physics will always be inaccurate

glacial notch
#

thanks a lot for all the info! and for bearing with my pedantic questioning, just tryna make sure it all clicks in my brain

bleak umbra
#

determinism doesnt change that

glacial notch
# bleak umbra game physics will always be inaccurate

I think in theory, thinking about it from a calculus perspective, within certain limits/assumptions you can get effectively perfect physics, much more so than the largely incremental & discrete nature of most game physics. but there are problems of how long that would take to implement and how costly it would be computationally

#

like you might have to use some cubic or higher-order curve intersection math, differentials and so on, but when a key press is detected within a step, the next step you can then calculate exactly what should've happen in the given time delta

#

you can even make it efficient by ensuring only some tiles are checked instead of the whole map, as is common for physics engines I imagine

bleak umbra
#

calculus in itself is terribly inaccurate, its just precise

glacial notch
#

well that's why I say limits/assumptions, in a fast-paced competitive game, it's not reality, you can think of everything being a vacuum or perfect solid, things move with no thrust, they just move, and acceleration can be instantly obtained or lost (i.e. forces) based on key presses

bleak umbra
#

i think you are overthinking all this

glacial notch
#

this is very unrealistic but within these limits it's arguably quite easy to devise a formula that calculates collision detection in a tile-based map etc

bleak umbra
#

you should first prove that there is an actual need to do all this extra work

glacial notch
glacial notch
#

anywho thanks again!

dreamy quail
#

what do you mean by drives?

#

ok i got it to work

#

but it feels....soft

#

sending vid

#

been messing around with the settings

#

it either bounces back and fourth

#

or feels soft

#

pls lmk if u find solution

stuck bay
unique cave
#

@dreamy quail id try fixed joint, just an idea. I dont really know if it would actually work

dreamy quail
unique cave
#

In order to achieve that, atleast the car should be moving using a rigifbody. Right after the cube gets hit by the car, you should stop controlling the cube so it can move freely

dreamy quail
stuck bay
#

Ah thanks

#

:)

dreamy quail
#

also please use obs or game bar

#

bandicam sucks

stuck bay
#

Yeah I know

#

my pc is potato

carmine basin
# dreamy quail it either bounces back and fourth

You can increase the spring and keep the damper the same, and you can also change the max force. I find that setting the max force to the same number, or a multiple of, of the spring yields good results for vr hands.

unique cave
# shrewd umbra okay thx

did you try unparenting the wheels and adding the wheel joints to the wheels (and not to the frame)?

shrewd umbra
#

"Bike" is an empty game object

#

for the back wheel i have to use a spring joint

#

when i use a wheel joint this happens

#

look at the green line as the bike rolls

#

the bike drops down

#

every 180 rotation

#

because the green line which is the wheel joint turns with the wheel

unique cave
shrewd umbra
#

im not gonna use motors anyways

#

and the way that i have the back wheel set up with the connector there is no way to make it work with the wheel joint

#

anyway its fine now

#

im making the movement with rigidbody

#

and forces

#

thats what it looks like now

#

but as you can see the tube is glitching

#

like it doesnt catch up with the bike

#

its like teleporting

#

u know how to fix that?

carmine basin
bitter meteor
#

The lower legs (including the feet) have collision detection set to continuous

#

and obviously i never mess with rotation of position manually, its only controlled through xDrive

carmine basin
#

Hm, is that just a plane you're using?

#

Like, for the ground

bitter meteor
#

Yeah

bitter meteor
#

@carmine basin

timid dove
# bitter meteor <@524671365056430113>

Can you try "continuous dynamic"? I notice your leg movement is largely rotation, I believe continuous dynamic does better with rotational tunneling vs continuous

bitter meteor
#

Didnt consider if it was slightly better or not tho

carmine basin
#

I find that planes have penetration problems usually

bitter meteor
#

yeah a cube worked way better

#

thanks @carmine basin

#

shame though

#

can i increase the physics steps per second or smth to make the simulation run "smoother"?

#

still getting a lot of impact forces

timid dove
#

if you make that smaller you'll get smaller physics timsteps

bitter meteor
#

Cheers ill try it out

carmine basin
#

Alternatively, if you want to make it bounce less, is there some kind of damping?

bitter meteor
#

@carmine basin you mean on the articulationbody joints?

#

There is damping but of course i have no idea if my joint parameters are reasonable or not

#

I barely know what the damping parameter actually does

carmine basin
#

I've never looked at Articulation bodies

#

can you show me the inspector window for them?

bitter meteor
#

those are not the actual values im using, i am changing them all through code since i got so many joints

#

@carmine basin

carmine basin
#

Hm, try reducing the x drive stiffness and increasing the angular damping at the top

bitter meteor
#

this is stiffness 3k

#

problem is that with stiffness too low it will not even attempt to lift itself

carmine basin
#

hm

#

put the stiffness back to what it was

#

try changing the angular damping

#

You could also try reducing the mass too,

torpid marten
#

can someone with a big brain help me out?
I'm looking for a way or formula to apply X force to reach but not surpass a given velocity, my designer brain is can't wrap iteself around it (using rigidbodies)

torpid marten
#

that is exactly what I am trying to avoid with this

timid dove
#

why

#

that's the end effect you want

#

any math will get you there precisely

torpid marten
#

no, I want it to be able to overshoot the velocity treshold by other forces

timid dove
#

other force applied in the same frame?

#

or what

torpid marten
#

possibly but others as well

timid dove
#

You need to carefully describe what you want then

torpid marten
#

basically I want an "engine", something that applies force but will eventually stop accellerating at its "limit" (the given velocity), but something like strong wind should still add acceleration to make it go even faster

#

(sorry for grammar, Im doing my best^^)

#

a car will reach eventually the max speed limit it can achieve and what im looking for is a way to set this limit as a velocity, without restricting it to that velocity

timid dove
#

Can't you just do something like:

float maxSpeed = whatever;
float currentSPeed = rb.velocity.magnitude;
float diff = maxSpeed - currentSpeed;
diff = diff < 0 ? 0; diff;
float desiredSpeedAddition = Time.fixedDeltaTime * engineAcceleration;
float speedToAdd = Math.Min(diff, desiredSPeedAddition);
rb.AddForce(direction * speedToAdd, ForceMode.VelocityChange);```
#

basically limiting the velocity change from the engine to the diff between current speed and max speed

torpid marten
#

itll take me some minutes to fully comprehend the code but I think this sounds like the solution Im looking for

#

my trouble was not understanding the relationship between adding force and the resulting velocity change of that force, making it difficult for me to figure out how to only apply the force needed and not much more

#

but this seems to be promising seeing that theres an addForce in there^^

timid dove
#

VelocityChange removes all the mystery from that math

#

you get to ignore everything like mass and time

torpid marten
#

perfect, thank you very much

potent notch
#

trying to create some planetary gravity type stuff with nvidia flex, which means i need someway to += a vector3 that will add force in the direction of the center of the planet, i also have each fluid paritcle's inverse mass stored somewhere incase that helps, and this is all being done in the fixed update, anyone got any ideas?

potent notch
remote pewter
#

This problem has bugged me, is there a good way to prevent ragdoll limbs from trying to "explode" from each ?
when you turn enemy into ragdoll with a raycast ?
Have to disable animator for this to work. I believe this bug is part of penetration recovery

public void ActivateRagdoll()
    {
        foreach (var collider in colliders)
        {
            collider.isTrigger = false;
        }

        foreach (var rigidBody in rigidbodies)
        {
            rigidBody.useGravity = true;
            rigidBody.isKinematic = false;
        }

        Destroy(this);
    }```
I'll try to make video when I can lol
warm moat
#

Hello everyone, I am currently doing an entry task for a job and i can't figure out how to solve it. I need to make two objects pull towards the point and when they collide with each other - bounce them away and change the colour of a piece where collision occurred. I found out that to change colour object has to have rigid body component, but if i use RB for every small cube, how do i keep them in place? And if i use RB on parent object to keep them together i cant change colour of small pieces because collisions wont register. Please tell me what would be the correct approach here. Thank you!

tender gulch
# warm moat Hello everyone, I am currently doing an entry task for a job and i can't figure ...

With composite colliders, one way you could do it is get get the object closest to the collision point.

Otherwise you could try using individual(non composite colliders) with kinematic rbs. In this case I'm not sure if there might be an unexpected behavior. Got to test it.

Lastly, you could try linking dynamic rbs with joints and configuring them to hard lock the rbs to each other.

carmine basin
upbeat birch
#

There is no way to manually check a collision between a Convex Mesh Trigger Collider and a Box Trigger Collider, right?
I construct a mesh on the fly to find an arbitrary number of selection boxes within it. Documentation insist that OnTriggerEnter requires not only Mesh Collider to work, but a Rigidbody as well. As the result I need to apply two components to a constructed mesh and wait until the next Fixed Update for OnTriggerEnter to fire properly. On the other hand I don't need to iterate over all selection boxes and check for boundaries.

void blade
#

Hey, I have a problem. As soon as I press play, my rigidbody flies away to one side. But in another scene it works fine. So it must be the scene and not the object. The physics settings are ok and I don't have a wind object. What could be the reason for this?

timid dove
#

a script doing it

#

an object pushing it

#

¯_(ツ)_/¯

#

with no details how could we know

void blade
timid dove
#

it could be something simple, yes

#

that doesn't mean mind reading is possible

void blade
#

Do you know some simple errors that can cause this?

inner thistle
#

You're not going to solve the problem with blind guesses

#

Show the code and the object setup

timid dove
stuck bay
#

How would one approach cross-sectional collision in a 2d project with 3d mesh colliders, kinda like what Getting Over It has?

#

(assuming this IS how it works)

tender gulch
hearty tulip
#

hey team, looking for a bit of help. i want to have a gameobject be connectd to another larger on and have it rotate freely 360degrees, then when i rotate it to the postion i want it to ingame i wanna be able to then make it push from the new direction the game object is facing

#

kind of like a tank turrent would spin freely

tender gulch
#

Does it have to be done via physics?

hearty tulip
#

yes exactly

#

id like to do be cause there is two outputs

#

two outputs operating independently

tender gulch
hearty tulip
#

oh sorry im bad at wording things. so im making a boat simulator with two propellers on the end of it one on each corner and i want them to both spin freely and independent from everything else. but when i push my forward key i want one of the propellers to push in the new direction its facing

#

im very new to unity so i have prob made a very rookie error, more then happy to share my screen with you to explain it better if youre happy to do so

tender gulch
#

Do they need to be spined by physics? So you actually need them to push the boat? Is it a hyper realistic boat simulator?

hearty tulip
#

i would like it to be a hyper relistic simulator one day. but for now i would like them to just turn without effecting anything

tender gulch
#

Then just turn them via transform or something. Don't add rbs to them

#

And apply the force to your boat instead of the propellers

hearty tulip
#

ahh okay that makes sense. I just want one force to be applied from one corner of the boat and another force from the other end

#

if you google ASD tug boat it might make sense what im trying to say

tender gulch
hearty tulip
#

okay thank you will do. appricate the help

tender gulch
hearty tulip
#

thanks a million

frail lagoon
#

In the top left corner, you can see if the player is grounded or not

cerulean kindle
#

I'm currently having a strange issue with opening and closing doors on my map, and it seems to be something to do with the box collider. I have it set up so my cursor highlights when something can be clicked on, so you can get a pretty good idea as to how far I need to go into the 'hinge' in order to be able to open and close the door.

I'm hoping someone might be able to assist me in this. With gizmos on, I do see that the Box Collider that I have on is following the path of the door so I'm not sure what's going on.

timid dove
#

A typical approach here would probably be to have a secondary trigger collider that doesn't move with the door so you can continue to interact with the space where the door used to be after it swings away

cerulean kindle
cerulean kindle
#

It's nothing fancy re: the raycasting.

    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        if(Camera.main)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform != null && hit.distance <= 2.5f)
                {
                    if (hit.transform.tag != "Untagged")
                    {
                        Cursor.SetCursor(activeCursor, new Vector2(0, 0), CursorMode.Auto);
                    }
                    else
                    {
                        Cursor.SetCursor(inactiveCursor, new Vector2(0, 0), CursorMode.Auto);
                    }
                }
                else
                {
                    Cursor.SetCursor(inactiveCursor, new Vector2(0, 0), CursorMode.Auto);
                }
            }
            else
            {
                Cursor.SetCursor(inactiveCursor, new Vector2(0, 0), CursorMode.Auto);
            }
        }
    }
#

Ah interesting, I always skipped over that parameter.

timid dove
#

TL;DR - by default yes raycasts will hit triggers no problem

#

you'd have to go out of your way to make that not the case

cerulean kindle
#

Okay perfect, thank you. Let me see how this goes.

#

Yeah looks like that did the trick. I do find it hard to believe that it's super out of range though, I can reach things further than that when I'm looking straight at them.

#

It just seems like something to do with the Door Frame blocking interaction.

timid dove
frigid stirrup
#

I have a image of a ground, so I used a UI element to position it somewhere, and I have a 2d sprite (square), is it possible to detect if they collide (ping me if you reply)

timid dove
dreamy quail
#

the first 30 secs are oculus being a jerk so u can skip it

#

the paddle is a rigid body with a configurable join

dreamy quail
#

tried the whole one object continuous and one object continuous dynamic

#

no fixes

dreamy quail
#

i fixed it

#

but if i have a bouncy object

#

it will bounce off the object rather than forcing it forward

#

only when going fast

carmine basin
#

@dreamy quail What you want is this - bouncy physic material on the ball. The ball bounces, so that makes sense. Do NOT put your physics timestamp on 0.001

#

*timestep

#

Instead, go into the physics tab of project settings

#

and turn up the velocity solver iteration a little bit

#

if its 6, put it on 8 or 10

#

And then

#

on your paddle

#

turn on Interpolation

proud trellis
#

Does anyone know, why in additive scenes [mirror multiplayer + server], some boxcast/trigger collisions happen only when there's a camera sitting and viewing it? [Yes, I am calling PhysicsScene.RunSimulation]
For a melee weapon, its a 10% hitrate [getting callbacks] on the server if I don't have a camera overlooking the entire scene. 90%+ if I do have a camera.
The camera is doing basically nothing just overlooks the entire scene on the server, I added it because I noticed a behaviour, where my chances of getting a trigger callback increased drastically if the object I'm hitting was in focus in the scene view.

dreamy quail
carmine basin
#

Take a guess

#

If you want a bouncy material

carmine basin
#

Yeah, turn those up

#

Regular iterations to 8 or 10

#

velocity solver iterations to 2

dreamy quail
#

oh

#

ok

carmine basin
#

what's your fixed timestep?

dreamy quail
#

i reset it to default

carmine basin
#

alright

dreamy quail
#

0.02

carmine basin
#

okay good

dreamy quail
#

ping pong ball mat

#

still not bouncy enough

carmine basin
#

Put the bounce combine on maximum

dreamy quail
#

only bounces once

carmine basin
#

That'll make it bouncier

dreamy quail
#

it bounced off the edge of the world

carmine basin
#

Then lower bounciness, keep it on maximum

dreamy quail
#

ok

carmine basin
#

it's because you have the bounciness on 1

dreamy quail
#

ok

carmine basin
#

Set it to 0.8 to 0.9

#

should give you fairly realistic behaviour

dreamy quail
#

i set it to 0.6 and it worked ok

#

but the paddle still phases through at high speed

carmine basin
#

Is the paddle rigidbody set to interpolate?

dreamy quail
#

a little bit of force gets applied but only a little

dreamy quail
#

o

#

i turned it off when debugging yesterday

#

ill test it in a bit, thanks for the help!

carmine basin
#

no worries :)

dreamy quail
#

:)

balmy raven
#

Hello I’m looking for Free GDD template

dreamy quail
#

@carmine basin your fixes are working great :D

#

thanks

#

the driver is still a bit wonky

#

if you have any settings or suggestions feel free to ping me

#

have a great day

carmine basin
#

@dreamy quail just in case, make sure that your paddle is NOT kinematic

carmine basin
#

good

fluid python
#

I have a rip of a mesh of a chain flail and bones associated with it, I want to simulate the chain. What approach can I use to do this and have it attached to a hand.

#

kinda got it working with cloth component but it wouldnt track the hand and the meshes ball would detach and fall away

unique cave
near scroll
#

Trying to use ConfigurableJoints and running into a quite unexpected problem..

#

Lets consider the above setup

#

The heirarchy looks like this

#

Blue and Red cubes are related.
Red is the child, Blue is the parent

#

Yellow cube is separate and is only used to push the other cubes around

#

All the cubes have rigidbodies

#

The blue and red cubes have Configurable Joints

#

Both joints are configured to allow Linear movement in the Z Axis

#

You can see the "Range" of motion depicted in the above picture by a red line

#

and you can see the anchors of the objects depicted by red spheres at the centers of the object

#

Here you can see the expected movements

#

The red cube has a smaller range of motion, and drags the blue cube along when it moves further than the limits of their constraints

#

The blue cube however, acts as a parent. and instead of Dragging the red cube behind it, it hard attaches and maintains the offset between the two cubes

#

This works fine when moving the objects through the editor

#

however, consider if the yellow cube is the one trying to interact with these objects

#

Here you can see the issue..
The yellow cube ONLY PUSHES the blue cube. The red cube stays in its position until the limits of configurable joints are surpassed and THEN it gets pulled by the blue cube

near scroll
#

I apologize for hogging the chat, the issue was highly specific and I needed to explain it thoroughly

lavish forge
#

⚠️ ⚠️ ⚠️ INEXPERIENCED QUESTION ALERT⚠️ ⚠️ ⚠️
So, i got a parent object with many child objects
Following issue:
I wanna have the child group work entirely as a fixed joint modifier
and i´ve applied it to all of them
and connected my joint modifiers to the parent´s rigid body
BUT everytime i launch the SIM the child parts explode and dont stay in place connected
Any posssible help is totally welcome
(by exploding i mean they seem to clip into eachother and get launched to the shadow realms around the globe)

viral beacon
#

Does anyone know why a capsule rolling on its side as the result of torque accelerates more slowly when its height is increased

#

I thought it had something to do with the volume of the collider, but when I added a box inside of the capsule that actually made it move faster

#

all of the rigidbody properties were kept the same in these tests

#

I hope to use sphere colliders as wheels in a driving game im working on but want to understand why there are differences in behaviour when height changes. I would prefer not to resize colliders at runtime to avoid akward collisions so I would like to understand how to simulate the effect these variations in height have on the simulation.

#

I wouldnt even mind that much if it were just a slight change in the rate of acceleration but it is rather tramendous just for slightly greater height values.

worldly dirge
#

im trying out unity's ragdoll system, and i have it so that when the player touches the car, it ragdolls. but the ragdoll goes strait through the car

worldly dirge
lavish forge
#

Thought you were using the Fixed joints component to do the ragdoll because i too had a similar issue, but if not, cant really help sorry

lavish forge
merry sleet
#

Hello! I might bring forward a rather stupid or perhaps even not adapt for this channel type-of question.
I've been working on a small simulation using ants which move on their own and, so far, everything's working great, all except my collision detection script.
I've tried using various methods already but I fail at getting a reliable working one. I've tried the following:

  • Using a single raycast in front of my ant and, if a collision is found, find a point on its reflection and move straight to it. This is the one which worked the most, though I have issues in situations where my ant is avoiding an obstacle (with this method) and happens to be on a plain face - this simply makes my ant stop as the reflection becomes a reflection of itself, and on, and on.
  • Using three raycasts as sensors and check which one is closest to the obstacle, then avoid by shifting my direction either left/right. This seemed to work but it has great issues as I cannot get my ants to reliably move so quick that they avoid them in time by simply changing their direction, especially in tight spots, where they simply no clip into walls.
    Does anyone have any other idea to face any of these issue? Sorry for the wall-of-text and weird question. Thank you!
    TL;DR: I need a reliable collision-detection which works fine in even "difficult" scenarios.
#

This is my code for the first solution; and this is basically the issue

#

[weird drawing i know]
orange is the supposed path; blue is what actually happens.
The ant usually avoids all kinds of obstacles as whenever it finds one, it keeps avoiding until the way is clear.
But in these cases, it is closer to go towards a direction that never leads to a target, and it simply gets stuck there.
Sorry and thanks again for all this stuff that perhaps is just stoopid.

bleak umbra
lavish forge
bleak umbra
#

Agents must maintain a minimum distance and be able to stop movement if no valid options exist for them

merry sleet
bleak umbra
merry sleet
bleak umbra
#

yes, first prevent collision by stopping then avoid stopping by steering away early

#

And you don’t need the reflection, just steer to the side of the agent that the obstacle normal points to until there is no more collision detected

merry sleet
#

Mmh I see, I'll try implementing something like that.
Thank you!

bleak umbra
#

I think your reflection logic introduces too much chaos into the behavior which prevents a plausible swarm behavior

merry sleet
#

I see, figuring out that as well. Though it was the only reliable method I had found for some "basic pathfinding"

bleak umbra
#

it certainly makes some sense

#

but it has too many edge cases

merry sleet
#

Basic pathfinding being something like this, simply it keeps avoiding until a way is clear.

bleak umbra
#

you should not use pathfinding for avoidance

merry sleet
bleak umbra
#

it’s too expensive for that

merry sleet
#

I was kinda using it for both, as I needed it for other reasons as well.

#

i was kinda using it the opposite, using avoidance in order for the ants to find a path to a certain target in the map while moving.

bleak umbra
#

use pathfinding to bias your avoidance&steering such that it returns to the path provided there is no obstacle

merry sleet
#

Uh, alright to be fair I have no clue of what that is but perhaps I mispelled it. I'm not using any kind of built-in pathfinding or something, it was just a way I called "ants finding a way to a target". Like, I'm not using any NavMesh or anything.

bleak umbra
#

it’s normal that steering and avoidance get your agents stuck in complicated situations (with many other agents)

bleak umbra
#

it’s just knowledge on how to go from a to b

#

you use steering behavior to follow such information

merry sleet
#

Ok, ok I understand it. Yeah.

bleak umbra
#

and avoidance to deal with incidental obstacles

merry sleet
#

I'm trying to use simply steering, like a direction that the ant desires to follow

bleak umbra
#

if you want to use ant colony simulation to find paths that is fine, then you just need a way for the ants to communicate their results (scent trails)

#

this is actually not an efficient algorithm for pathfinding but can look quite interesting when observed

merry sleet
#

Yeah regarding that, I was going to follow into that as well, but I've been getting a lot of issues with avoidance itself, perhaps even stupid issues.

And yeah, I'm mainly going for it to be interesting, not too much for the performance. Tbf, I like ants.

#

Alright, thank you a lot for your help! I'll try working with steering and avoiding reflections; and probably improve and a function to properly handle some more precise steering.

bleak umbra
#

Ant colonies are great for solving traveling salesman like problems

merry sleet
#

Aye.

north condor
#

Does anyone know which one is more demanding? Rigidbody + OnTriggerEntry/OnTriggerExit vs. Physics.OverlapBoxNonAlloc on FixedUpdate on a setup like this

#

I just need to check whether the boxes are inside the virtual shelf

bleak umbra
#

Physics are black box, assumptions are dangerous

#

In theory the OnTrigger should be more efficient, but maybe not

north condor
#

Yes, this is my current solution

bleak umbra
#

If your do the overlap test incrementally (not every frame and spread out) it can be much more efficient

north condor
#

Ugh.. I don't think I don't want to implement that

#

I am trying to get every FPS I can get because of the hardware limitation of the HoloLens 2 device

bleak umbra
#

Profile and see if your current solution is good enough

#

Colliders that don’t move are basically free

north condor
#

When is OnTriggerStay called though? When they move inside?

bleak umbra
#

on trigger is also just the result of an overlap check

#

But the check is only triggered if the object has moved since the last update, was enabled or otherwise awoken

north condor
#

Ahh okay. That's gonna be messy since I'm tracking real life objects and they might jiggle a bit

bleak umbra
#

well, off to the profiler then

north condor
#

And that's like 21 boxes

bleak umbra
#

idk what performance a holo2 has but it surely can handle a few primitive overlap checks

north condor
#

This is what I see

bleak umbra
#

Maybe reduce the fixed update rate

north condor
#

Under time right?

bleak umbra
#

maybe, it’s somewhere

#

if you don’t use physics for much else you can slow it down a bunch

north condor
#

Assuming it's this:

bleak umbra
#

Yes

north condor
#

The only thing it affects is the UI I suppose

#

it's all collider based

bleak umbra
#

yes

#

and it makes your framerate unstable

#

but really, profile before you do any of that

north condor
#

I'm not at the lab but I am trying to figure out what else is affecting my performance. Profiler data is portable right? I don't know how to decipher this

#

Can't recreate my performance issue at home :(

lavish forge
#

So, i got a parent object with many child objects
Following issue:
I wanna have the child group work entirely as a fixed joint modifier
and i´ve applied it to all of them
and connected my joint modifiers to the parent´s rigid body
BUT everytime i launch the SIM the child parts explode and dont stay in place connected
Any posssible help is totally welcome
(by exploding i mean they seem to clip into eachother and get launched to the shadow realms around the globe)

#

(Sorry for repost)

worldly dirge
worldly dirge
#

nvm fixed it

hearty tulip
#

hey guys im just looking for a bit of help im trying to make an asd tug boat simulator. which in short has two propellers at back of the boat which can rotate 360 degrees independently and push one object ( the tug boat) around on diffrent angles ill attach a link to an old game from 2006 which seems to have done it but its not very realistic. thanks.

#

i really am just trying to work out how to have two forces act on one object

urban rover
#

Hey, when using capsule cast, is it possible to get the mid point of the capsule on collision?

timid dove
#

the RaycastHit has a distance property

#

you do:

rayOrigin + (rayDirection * hit.distance);```
#

that'll be your capsule's midpoint where it is when the collision occurs

#

this is opposed to hit.point which is the point on the capsule surface where the collision occurs

urban rover
#

Yea I thought distance was just the length between capsule origin center and hit.ooint, but it's actually the distance the capsule travelled before colliding huh

#

That's exactly what I need

near scroll
#

I have an object with configurable joint on it. I have also given it its own Layer to operate on
I've set the flags in project setting to make sure that this layer doesn't collide with ANY other layer
Yet somehow for some inexplicable reason, colliders from other layers still mess this object up

#

whyyyyy

dawn plank
merry sleet
#

Hello! Sorry for another, yet, probably simple question. I've been working on a steering behaviour system (as suggested yesterday by someone I'm very grateful to for sharing all that knowledge) and it's roughly working for now, at least I'm understanding what is going on, though I face an issue (which I already faced before with another system) which is collisions.
My issue is simply my not understanding on how could I communicate to my agent where to go to avoid the obstacle, and more precisely, how to give it the right direction in which to avoid.
I use a "steering" system for the agent movement in which multiple functions contribute in order to get a final velocity value; my avoidCollision does the same thing, but I'm struggling to get it work.

#

I hope this drawing kinda transmits the message. Thank you. My issue is basically how should I detect where to go after using a raycast there.
A document I've read used the collision body centre as a reference to avoid, but I do not find it viable as my map is an enormous collision shape.

tender gulch
merry sleet
bleak umbra
#

You can use 1 - the absolute value of the dot to drive turn speed based on the acuity of the angle between the ants movement and the collider surface @merry sleet

merry sleet
#

@tender gulch @bleak umbra Thank you both a lot for the info. I never thought about using dot products, I've read up a bit on them and refreshed them in my mind and definitely seem useful. I'll try today and see what I can manage. Thank you a lot again!

bleak umbra
merry sleet
#

Thinking about it - using the right direction only wouldn't that give issues, considering other cases like if the ant is going vertically, etc-

#

Very weird drawing lmao
In this case, for example, if I happen to use the right direction of my velocity, wouldn't it happen to give a wrong result (cos would be higher than 0, giving me a positive, but would have to give a negative in order to turn right)

tender gulch
cerulean kindle
#

Are you able to specify physics-zones, so one area of the map has lower gravity than the other?

merry sleet
tender gulch
cerulean kindle
#

Well I was trying to make it so one gameObject had no gravity so when it got force applied to it, it would just float away - but that wouldn't work until I eventually just changed the Physics.gravity value.

tender gulch
#

Not if you apply gravity manually

#

Gravity is just a constant force applied to rigidbodies

#

You can do it absolutely the same way as unity physics does.

#

+make different objects receive different force

cerulean kindle
#

Okay so I'd do something like...

#
gameObject.getComponent<Rigidbody>().AddConstantForce(new Vector3(0f, 5f, 0f) * 5);
yield return new WaitForSeconds(5f);
gameObject.getComponent<Rigidbody>().AddConstantForce(new Vector3(0f, 0f, 0f));

Or would I need to negate that 5f with -5f ?

tender gulch
#

Yes, except that there's no AddConstantForce method.

cerulean kindle
#

Yeah I just saw that, my bad. I see it's a separate component.

tender gulch
cerulean kindle
#

So it'd just be a case on enabling/disabling that component

tender gulch
#

Rigidbody.AddaForce.

cerulean kindle
#
int i = 0;
while(true && i <= 100) {
    yield return new WaitForSeconds(.1f);
    gameObject.getComponent<Rigidbody>().AddForce(new Vector3(0f, 5f, 0f));
    i++;
}

I could do something like that then

tender gulch
#

There's nothing special about gravity. It's just another force applied to a body.

tender gulch
cerulean kindle
#

Would it even need to be in a coroutine at that point if I used FixedUpdate instead

tender gulch
#

It can't be physically both in a coroutine and a fixed update.

#

You could make the coroutine yield till fixed update if you really wanted it, but I'd just suggest using the update. There's no benefit in using a coroutine whatsoever.

cerulean kindle
#
public class ItemLevitation : MonoBehaviour
{
    int loopCount = 0;
    Rigidbody rigidBody;
    void Start()
    {
        rigidBody = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
        if(loopCount <= 100)
        {
            loopCount++;
            rigidBody.AddForce(new Vector3(0f, 0.2f, 0f));
        }
    }
}

Basically I can just attach this component to any object, and in a separate controller add and remove this component as needed in a co-routine.

#

If for whatever reason the separate controller fails to remove the component, at least there's a hard-check in place to make sure items don't float in the sky forever.

tender gulch
#

Didn't you want to have gravity zones initially?

cerulean kindle
#

Yeah I did but ultimately it's an AI that's causing things to 'levitate', but I just target it per-item instead of per-room/zone.

tender gulch
#

Maybe something like this?

//Fixed update
rigidbody.AddForce(CurrentGravityZone.GetGravity());
#

Then you can set the gravity zones on trigger enter/exit.

#

Would be easy to resize them in the scene view.

#

And if there's no gravity zone, apply default gravity.

cerulean kindle
#

That might be a better idea.

#

Do I need to do anything to make the FixedUpdate() start working once I add it to a gameObject dynamically?

#
    void LevitateNearbyObjects()
    {
        Collider[] c = Physics.OverlapSphere(transform.position, 3);

        foreach(Collider collider in c)
        {
            // Only levitate things if it has a rigid body.
            if(collider.gameObject.GetComponent<Rigidbody>())
            {
                collider.gameObject.GetComponent<Rigidbody>().isKinematic = false;
                print(collider.gameObject.name + " is marked for levitation");
                ItemLevitation itemLevitation = collider.gameObject.AddComponent<ItemLevitation>();

                StartCoroutine(ResetObject(collider.gameObject, Random.Range(5, 10)));
            }
        }
    }

    IEnumerator ResetObject(GameObject gameObj, float time)
    {
        yield return new WaitForSeconds(time);
        print(gameObj.name + " has stopped levitating");
        Destroy(gameObj.GetComponent<ItemLevitation>());
    }
public class ItemLevitation : MonoBehaviour
{
    int loopCount = 0;
    Rigidbody rigidBody;
    void Start()
    {
        rigidBody = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        if(loopCount <= 100)
        {
            loopCount++;
            rigidBody.AddForce(new Vector3(0f, 1f, 0f));
        }
    }
}

Seems to be firing but nothing is happening. Not sure if I need more force

#

Tried with Update() and FixedUpdate() hmm.

tender gulch
#

I don't see any of the updates in your code.

#

Ah, ok. I see it in update at the bottom.

#

You, should avoid this kind of checks. That's only gonna work for 100 frames. Besides, AddForce need to be applied in the fixed update.

#

Also, it's probably need to be in acceleration mode, since you want the same force to be applied regardless of object mass.

lucid obsidian
#

I'm a bit stuck on the physics 2D materials

#

my problem is basically this

#

The bullet also has a bounciness of 1 since I'm hedging my bets

tender gulch
#

How are you moving it?

lucid obsidian
#

In the void start

//Set initial movement vector
        Motion = transform.TransformDirection(Vector3.right * velocity);
        rb.velocity = Motion;

velocity is a vector 3 assigned by the gun thats basically direction gun is pointing at 25 speed

tender gulch
#

Hmm

#

What collider does the bullet have?

lucid obsidian
#

weirdly if I tell it to

Destroy(this.gameObject);

on contact with the wall using a private bool and allow it to bounce before the destruction code can trigger

#

it will bounce perfectly on the times its not destroyed

#

Bullet is using a circle collider 2d

tender gulch
#

If it's called on collision it should be destroyed the moment it collided.

lucid obsidian
#

Just making the collission check less accurate by messing with the istrigger variable

tender gulch
#

🤔

lucid obsidian
#

this is my whole update

private void Update()
    {
        //Break if hitting terrain
        if (Collide())
        {
            Instantiate(hitSound, transform.position, transform.rotation);
            Destroy(this.gameObject);
        }

        if (InPlayer())
        {
            col.isTrigger = true;
        }
        else if (Collide())
        {
            col.isTrigger = true;
        }
        else if (Mirror())
        {
            col.isTrigger = false;
        }
        else
        {
            col.isTrigger = true;
        }
    }
#

collide is a collision check for the black walls

#

if I remove the bottom thing controlling the trigger and just leave it on, and change the mirror walls to the regular wall materal

#

its about 33/66 that it bounces perfectly or gets destroyed like it should

tender gulch
#

Is it a trigger initially?

lucid obsidian
#

yes

tender gulch
#

Then how do you expect it to bounce?

#

Triggers don't collide with things.

lucid obsidian
#

because it stops being a trigger if Mirror() which is a private bool checking if its touching the mirror wall

#

besides if that were the case it would go right through

tender gulch
#

Well, you can t expect it to start behaving normally if you switch it to a collider in the last moment.

#

We don't even know what moment that is. It could be before or after the "collision"

lucid obsidian
#

If I change it so that its a trigger when touching the player and not a trigger the rest of the time the issue persists totally unchanged

tender gulch
lucid obsidian
#

to stop it having physics interactions with the walls meant to destroy it

#

right now its doing the 1/3 chance of bouncing perfectly off the walls that its meant to be destroyed by

tender gulch
#

Why not destroy it on collision then? What does it matter if it interacts with them or not if it's destroyed?

lucid obsidian
#

because I want some walls to reflect it and some to destroy it

tender gulch
#

You can check that in the on collision method

#

I don't understand why you're making it more complicated than it has to be..?😅

lucid obsidian
#

It was the simplest solution using the code I've learned so far

#

still don't understand why it would bounce of one wall and not another

#

even if I literally copy paste the wall it bounces off

#

it won't bounce off the copy

#

and it I remove the code telling it to destroy itself it also won't bounce

tender gulch
lucid obsidian
#

so how would I run a collision method for each type of wall?

#

I gave em each different layer masks which is how I've been differentiating them

tender gulch
#

Just check the colliding object in OnCollisionEnter

lucid obsidian
#

I'll give that a try

tender gulch
#

You can check the collided object layer if you want.

lucid obsidian
#

I don't really see where to define a specific object or layer using oncollisionenter

#

would it be the second text here? "(Collision2D collision)"

tender gulch
#

Check what properties of Collision2D

lucid obsidian
#

Ok I re-wrote to this

    private void Update()
    {
        if (TouchPlayer())
        {
            col.isTrigger = true;
        }
        else
        {
            col.isTrigger = false;
        }
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag.Equals("Terrain"))
        {
            Instantiate(hitSound, transform.position, transform.rotation);
            Destroy(this.gameObject);
        }
    }
#

its definetaly a lot cleaner but I'm back to square 1

#

when hitting the non-killy wall it still won't bounce

#

what it seems to be doing is losing all X velocity then sliding up or down with whatever Y velocity it had at the time

#

Ok

#

it seems to be the platform effector

#

it makes things only bounce off horizontal surfaces but not walls

#

Thanks for letting me know theres a collision method

#

gonna save me a lot of pain down the line

oak crystal
#

So I'm currently having trouble implementing knockback. My goal is to have the player be knocked back in a curve using forces instead of position changes and to have the player still be in control of horizontal movement while being knocked back. I currently have the player being knocked back using MoveTowards desired positions on the curve but doing it this way the player will move through walls and can't move while being knocked back. Any ideas on how to do this?

#
    {
        knockback_r = StartCoroutine(KnockbackSequence(knockback, knockback_location));
    }

    private int numPoints = 75;
    private Vector3[] positions = new Vector3[75];
    IEnumerator KnockbackSequence(float knockback, Transform knockback_location)
    {
        //calculate p0, p1, and p2

        float horizontal_enemy_distance = knockback_location.position.x - rb.position.x; // horizontal vector distance from player to enemy
        float vertical_enemy_distance = knockback_location.position.y - rb.position.y; // vertical     ^


        Vector3 p0 = rb.transform.position;
        Vector3 p1;
        Vector3 p2;

        p1 = new Vector3(p0.x + ((1) * (-horizontal_enemy_distance / Mathf.Abs(horizontal_enemy_distance))), p0.y + (1) );
        p2 = new Vector3(p0.x + ((2) * (-horizontal_enemy_distance / Mathf.Abs(horizontal_enemy_distance))), p0.y + (1 / 4) ); //dividing horizontal distance by the absolute value of itself gives 1 or -1
        

        for (int i = 1; i < numPoints + 1; i++)
        {
            float t = i / (float)numPoints;

            desired_position = QuadraticBezierPoint(t, p0, p1, p2);

            rb.position = Vector2.MoveTowards(rb.position, desired_position, 1);
            

            yield return new WaitForEndOfFrame();
        }```
#

here's my current knockback code

near scroll
#

Man I so so so wish Unity had better documentation for ArticulationBodies and Configurable Joints

#

I mean.. What the hell am i supposed to infer from this. This is the sort of answer I'd write in a test if I didn't know how to explain what was asked

#

"where do you live"
"Beside my neighbour"
"where does your neighbour live"
"Beside me"

#

if someone could please explain the difference >.< I tried getting a feel for it by adjusting the values, though i'm not sure I understand

quartz wyvern
#

for the life of me i can't figure out why my raycast wont hit my gameobjects

#

i debugged the ray it hits it perfectly, they are on a layer that my layer mask is selected to

#

but still it wont detect a hit

#

if i remove the layer mask it hits everything

#

but i just want it to only hit these items on a specific layer and it will not work

quartz wyvern
#
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out RaycastHit h, _layerMask))
            Debug.Log(h.transform.name);
#

debug never happens

bleak umbra
#

show the _layermask field

quartz wyvern
#

and the object im trying to click

#

if i remove the layer mask it hits them but also everything else

#

so the layer mask is the problem

#

proof here

#

unless unity has some bug i dont know about

bleak umbra
#

looks all good to me

quartz wyvern
#

yeh must be a engine bug then

#

ill have to report it

bleak umbra
#

Certainly not a bug

#

you are doing something wrong that’s not yet on your radar

quartz wyvern
#

if i select Everything for the layer mask it selects the blue crystal

#

but if i specifically set it to the layer that the blue crystal is on

#

it wont ever hit

bleak umbra
#

I believe you

quartz wyvern
#

let me try a different collider to capsule

#

ok its a bug its fixed

#

and now i know for sure its a bug

#

if you use user layer 3

#

it don't work

#

but any other user layer it works

#

🤔

#

now its hitting everything with a custom layer

#

let me restart unity its bugging

bleak umbra
#

I think you are using the layer mask as distance

#

and never actually specify a mask

quartz wyvern
#

omg you're right

#

i just checked

#

didn't realise LayerMask has implicit conversion to float

#

thats annoying as hell

#

thing is i dont want to set a distance

bleak umbra
#

The problem really is that all the parameters have default values and you never notice that you omit the layer argument

quartz wyvern
#

yeh its taking the layer mask as a float

#

so its assuming its distance

#

and taking the wrong overload