#⚛️┃physics

1 messages · Page 72 of 1

last stump
#

Is there a way to detect if an Object is "on the ground" just by checking its velocity? Something like checking whether or not the Y velocity is the same as the Gravity force.

timid dove
#

That's also going to be true at a certain part of the jump

last stump
#

Found out the way, thank you!!

desert wave
#

how could i use general relativity instead of newton's gravity formula?
script from brackeys btw

const float G = 6.674f;

    public static List<Attractor> Attractors;
    public Rigidbody rb;

    void FixedUpdate()
    {
        foreach (Attractor attractor in Attractors)
        {
            if (attractor != this)
                Attract(attractor);
        }
    }

    void OnEnable()
    {
        if (Attractors == null)
            Attractors = new List<Attractor>();

        Attractors.Add(this);
    }

    void OnDisable()
    {
        Attractors.Remove(this);
    }

    void Attract(Attractor objToAttract)
    {
        Rigidbody rbToAttract = objToAttract.rb;

        Vector3 direction = objToAttract.transform.position - transform.position;
        float distance = direction.magnitude;

        if (distance == 0f)
            return;

        float forceMagnitude = G * (rb.mass * rbToAttract.mass) / Mathf.Pow(distance, 2) * .9f;
        Vector3 force = direction.normalized * -forceMagnitude;

        rbToAttract.AddForce(force);
    }
#

for gravity, taking in mind the perfomance ussage

vapid tusk
#

I have several colliders on my Player. Each collider is in a different child game object. When one of these colliders collides with a collider on another object, I need to know which collider on my Player hit the other object.
Using: OnTriggerEnter2D(Collider2D collision)
collision.gameObject.name OR
collision.gameObject.tag
give the name and the tag on the other object the Player collided with.
Is there a similar way to get the collider, or tag, or gameObject name, of the collider on my Player that hit the other gameObject?

last stump
#

If I set an OnTriggerEnter2D method on an Object whose Collider isTrigger, it will only be executed when it "collides" with another isTrigger collider right?

vapid tusk
last stump
#

Thank you so much

vapid tusk
#

@last stump You're welcome. I found that table very useful last week.

faint cairn
#

anyone experienced on Obi Rope?

#

i need to ask something about runtime

west shard
#

Hi, how can I calculate the needed velocity for y? I have a constant x speed and have the point the target has to reach as the highest point.

#

i thought about this formula but it gives me the vector v_0 how do i get the y component of it?

desert timber
#

The red lines are rays from ControllerColliderHit.point in the direction of ControllerColliderHit.normal. The player character is running and jumps along the wall at a shallow angle, touching the wall as he moves, from left to right.

At the top, there's a gap I'm not sure about? Perhaps it's late and I have a bug? Or is this expected behavior somehow, in that the hit.point is coming from a different point of collision since the player starts moving down instead of up?

desert timber
#

there are those 4 kinematic equations (with constant acceleration) that are wiggled around for what you need, more than one way to solve them

pliant fern
#

I've figured out that objects with less friction bounce more from it. But i dont want objects to always have little friction, so is there any way to set an object's friction on impact?

#

Actually nvm it doesnt seem to change anything all too much

#

ugh

#

I'm extremely stumped on how to make it more bouncy

subtle axle
pliant fern
subtle axle
pliant fern
subtle axle
pliant fern
subtle axle
pliant fern
#

ive tried modifying every aspect of the objects and the jelly and nothings been working

#

If that helps to understand how to fix it

#

i set the frequency on the spring joints to neighbors to 10, and instead of setting them to opposing bones like the tutorial i made a center bone and made a third spring joint connecting to it with a frequency of 2

inner plank
#

Hi there! Total beginner here. I could use a little help with collisions/rigidbodies. Should be really basic stuff I guess. Anyone up for a short 10 min call so I can describe the problem better?

timid dove
#

You could just explain it here instead.

#

DOn't worry we've seen it all

inner plank
#

I thought it'd be a little bit easier if I can show stuff but ok, I'll try:

timid dove
#

You can share videos or screenshots

inner plank
#

Basically, I've got a really really simple movement of a character that I really like and I want to keep the way it works, but lack of knowledge about the built-in physics makes it bork collisions.
Script is this one:
https://paste.ubuntu.com/p/Brw9FvyzCj/
Now what happens is I can sort of "squeeze" through walls.

I've researched a bit and apparently the best way is to just switch to RigidBody.MovePosition, which I explored as you can see in the script. But that just makes it worse, it still is able to go through walls and the movement becomes jagged. Surely there has to be an easy way to realize this movement?

#

this is the squeezing in question

#

It obviously recognizes the collider either way and tries to push out and I just translate too fast through it but how would I solve this

timid dove
#

since it's physics related it's be something you do in FixedUpdate

#

but really - you might have better luck with modifying the Rigidbody velocity instead

inner plank
#

I know I got this far (which is why there is a FixedUpdate stub)

#

Hmm... Kinda sad, I was hoping I could keep this simple because that's really all I need for movement

timid dove
#

I don't think setting velocity or doing MovePosition in FixedUpdate should be terribly complex

inner plank
#

MovePosition in FixedUpdate I tried, as I said

#

It's the same behavior just more jagged.

timid dove
inner plank
#

Yes, of course

timid dove
#

can you show what you ended up with?

inner plank
timid dove
#

you have colliders on both objects right?

inner plank
#

Yeah I do

timid dove
#

Wait is your Rigidbody kinematic?

inner plank
#

That's what has been confusing me for the past two hours

#

Nope

#

Player character is non-kinematic

timid dove
#

🤔

inner plank
#

Well the good news is, it doesn't go through walls now. However it controls a lot more awkwardly. Of course I can build around this and manipulate the velocity a bunch, I just had hoped that I might be able to avoid just that. :/ Anyways, thanks for the help!

timid dove
#

Ok cool. Not sure why MovePosition wasn't working TBH

#

as for the "jagged"-ness try turning on Interpolation in the Rigidbody settings

inner plank
vast meadow
#

@snow field id rather move here for this, could i get your settings for your wheel colliders?

#

im using them and have a serious sliding problem

heavy spoke
#

I've got a similar problem to volatile_integer's, except my moving object isn't colliding with walls at all 🤔 I've tried just about every combination of the moving object and the wall being Kinematic or not & the different combinations of interpolater's and collision detectors. Heres my code for the moving object if anybody can help
https://gyazo.com/8536c704364071c89f2bf4222f9cd303

#

You can see the paddle that follows the ball collides w/ the wall so idk why the pong isn't doing the same

#

I thought it might be because my code is causing it to constantly gain forward force to overwrite any collision but its reached magnitude > 3 by the time it reaches the wall so I don't think that line is running by then

#

Nvm, I'm a stupid idiot and 'Is Trigger' removes collision or something I guess 🙂

stuck bay
#

I want to turn off physics for my game but, I would like to use colliders. Is that possible?

pliant fern
#

It's bouncing great now, but the softbody is too slippery and easily gets stuck in things. How should I fix this?

pliant fern
stuck bay
#

and the collisions will be detected by a ray

pliant fern
stuck bay
#

@pliant fern ty

pliant fern
#

No problem :)

prime rain
#

I'm looking to have a specific rigid-body collider only apply friction based forces, no position or torque acceleratoin.

timid dove
prime rain
#

well its a collider on a child object, don't want the collision to effect the rigid-body on the root. I just want to know what forces it would have applied due to friction.

timid dove
#

or use a trigger collider

#

and do your own calculations

snow field
#

@vast meadow

#

the car wobbles when its on a race track though~

fresh gull
#

I gave both these objects a collider and rigidbody but the guy keeps falling through the floor whats wrong?

#

Nvm

timber jungle
#

I, too have a sinking in the floor problem :D but mine is a bit more weird

i basically have two cubes and on one side everything is fine, but when my little cube goes to a certain spot on the big one, it just slowly sinks/bugs through it till it falls out of the world

#

i have no clue at all what unity thinks is different about this certain spot, because there is nothing

timid dove
timid dove
timber jungle
# timid dove could be something in your movement script(s)

the 2 little cubes have the same code for that (tho it is controlled by ML - as that was what i was trying to get the hang of with that :D) but it still only happens to the grey one. they are the same size too (both blender default cube xD) thats why im starting to run out of ideas

timid dove
timber jungle
timber jungle
dull adder
#

fysics.

fiery patio
tiny notch
#

~~Hi guys, I am having a very weird problem:

My gravity appears to be being wrong. The image attached shows a cube, dropped from a height, after 10 seconds of continuous falling. As shown in the highlighted boxes in the middle and right, the cube has:
gravity = -9.81
rigidbody drag= 0.
No other components are acting on this rigidbody (I literally just attached it to the cube to debug the same problem on my player character), so this is not a problem of my resetting the velocity every frame myself, at least, not on this object. Also, there is no physics material attached to the cube collider

On the left red box
velocity = -58.46 in the y direction.
time = 10.1 seconds.

These values are not correct, see below:

Using v = u + at
-> v = 0 - 9.81 * 10.1
-> v = -99.08

I have no idea what I've done wrong. My only thought is that the units could be messed up, but I can't find anything about that online. Anyone have any ideas?

Update:
I have tried disabling gravity, and adding a separate acceperation of -9.81 downwards, problem persists~~

Worked it out nevermind (physics only starting after a few seconds has passed). Sanity restored!

urban plover
#

Hello everyone, i have a problem that i can't really think of a solution for.
I have a rigged character imported from blender into unity. i turned it into a ragdoll and so far everything's fine.
I'm working on a system where player can disable/enable ragdoll by clicking it. I checked it several times, the script is working properly.
the thing that detects player's raycasts is ragdoll's top parent which has a sphere collider (with "Is Trigger" enabled)
The problem is as ragdoll starts moving like normal, the sphere collider stays in the starting position forever and because of that, player has to click on ragdoll's starting position instead of ragdoll itself
As you can see in the picture, Ragdoll starts working but sphere collider, which is where player has to click, doesn't move (which is because it's attached to the parent)
another problem is if i remove sphere collider from parent and attach it to the ragdoll itself (armature) raycast won't detect it.

timid dove
#

you need the sphere collider to be at the same level or lower in the hierarchy as the primary dynamic rigidbody

tiny notch
# urban plover Hello everyone, i have a problem that i can't really think of a solution for. I ...

"the thing that detects player's raycasts is ragdoll's top parent which has a sphere collider (with "Is Trigger" enabled)"
You cannot have the collider track the model if it is attached to a gameobject which is a parent of the object it is tracking, because moving it will also cause the model to move.
Attach the collider to a new game object which is a child of the model is the right solution. It's strange that this isn't working. I suspect that the armature of your object has the same origin even when the bones move. I'd make it a child of one of the bones instead

timid dove
#

Basically - make the sphere collider a child of e.g. the chest bone or something

bold yew
#

Any idea why this happens? It doesn't matter who is the host and who is the client, the one in the built version always has legs that drag behind. What about the build could have caused these procedural legs to lag behind in the built version?

slim mantle
#

Dunno if this is exactly physics-related, but I have questions regarding, uh.. stars..

sharp heath
#

I'm a virgo

#

How do I improve physics collision on my project

#

I can phase through walls if tried

ember violet
#

I was working on a golf project and am facing a bug. Whenever the golf ball rolls from the fairway -> fringe -> green (3 different sections of the golf course with their own respective mesh colliders), I get unexpected jumps and bounces. I tried making the "Project Settings -> Physics -> Default Contact Offset" around 0.0001 as I had read on a few other threads that this might fix my issues, however, I had no such luck. I cannot restrict the ball's Y position as the golf course has some slopes and the ball, therefore, needs to be able to move along that axis. Can I have some help with this? (https://i.imgur.com/KPsR7tW.jpeg screenshot of the bug I'm facing)

sacred parcel
#

Hi umm, why isn't this physic material applying to the box collider? Can anyone help?

#

Nevermind, found it!

lament pagoda
#

I have a player object with a kinematic rb. It does collide with one enemy type, but not with the other, even though they are on the same Layer and their rb are exactly the same

civic field
#

from the doc

#

if that's not it then check your colliders

#

and your collision matrix

lament pagoda
lament pagoda
lament pagoda
civic field
#

then either send screenshots of the 3 objects or simply build the other enemy from the working one.

lament pagoda
#

Thats one enemy type.

#

Thats the second one

#

And thats the player

civic field
#

Since it's 2D it should be not that hard to build one from the others and you'll probably find the issue that way

lament pagoda
#

That was exactly my thought process. I replicated the melee prefab and just changed the attached movement script, as well as the color, and suddenly it the ranged enemy cant collide anymore. The movement script from the ranged enemy inherits from the melee script.

lament pagoda
#

Is it possible, that constraints, such as freeze position, disable collisions?

manic dock
#

How many units per seconds do things fall under normal gravity settings?

timid dove
#

they accelerate at 9.81 meters per second each second

#

so after 1 second they will be moving 9.81 meters per second down, assuming they started from rest

manic dock
#

oh cool

#

is there any code you can write to find out how long something will take before it touches the ground

timid dove
#

You can calculate that using kinematic equations, yes.

#

take any of the equations where you know all the variables except for t and solve for t:

manic dock
#

Alright I'll do some more research on those thanks!

sacred parcel
#

I can share the code if needed.

wide nebula
#

Obviously nobody is going to be able to answer that without seeing the code.

sacred parcel
#

It worked with the in built sprites like basic shapes, but didn't after I put in the new model.

sacred parcel
wide nebula
sacred parcel
#

But it is multiplied by -0.5f.

wide nebula
#

Look at the pattern of your four function.

#

When you're moving right, you're applying the WalkRightVector, and vice versa when going left. Except on line 78, you used the opposite.

wide nebula
#

If that doesn't solve it, then just make sure your WalkLeftVector is actually pointing to the left in your inspector.

sacred parcel
#

Sure thing!

sacred parcel
#

Silly me!

dreamy pollen
#

I use rigidbody physics for my player, and am realizing that I have stutter due to using transform.rotation =. There probably is not an easy way to convert my rotations to angular forces, but maybe someone here has experience with it and can provide guidance?

timid dove
#

torque is "angular force"

#

you can also do Rigidbody.MoveRotation (in FixedUpdate)

dreamy pollen
# timid dove Rigidbody.AddTorque, basically

Right, Rigidbody.AddTorque is what I intend to use. The trick is figuring out how to convert my rotations that I was previously applying to the player into equivalent torque forces

timid dove
#

but... yeah torque is torque. 1 unit of torque will accelerate the rotational velocity of an object with inertia tensor of 1 by I think... 1 radian per second^2?

uneven shore
#

any chance OnTriggerEnter2D doesn't trigger when enabling collider 2d, and colliders intersect already?
And if so, what can I do about it?

tiny notch
# dreamy pollen I use rigidbody physics for my player, and am realizing that I have stutter due ...

I've recently finished struggling with this, it can be a headache even with addTorque.
See here for some useful conversion functions between toque and rotations per second. https://gist.github.com/ditzel/1f207c838f0023fcbd34c5c67955fd25 (not mine, they came from https://www.youtube.com/watch?v=BNiAt0HnC5M). What you need to do is to decide what fraction of a full rotation you need to cover in a single fixed timestep t (eg, 2 degrees of rotation per frame), then plug that into the rotations per second (RPS) to torque calculator. If that rotation would take you past the desired rotation (ie, the rotation is complete on the next frame), subtract the remainder so that you end up exactly at the desired rotation. If it is a character rotating, it will also look better if it is nonlinear, eg, to have a low RPS at the start of the rotation, high in the middle, and low again at the end. You can use a sin wave for this. Find the time required for the full rotation to complete (call this T)- which should scaling linearly with the angle between current rotation and the desired rotation. Then use _RPSMultiplier = sin(PI * physicsTimestep/T). Multiply the RPS you use by 2 * _RPSMultiplier, this way your average RPS will be approximately the value of the original RPS value you set. You could also use an animation curves for more fine grain control than the fixed values a sin wave will offer

However, the problem may well be with your camera too. Make sure the rigidbody is set to "interpolate", and that the camera is not a child of the rigidBody gameObject, and should track the rigidbody in lateUpdate. You might still see some subtle stutter after doing this. God knows why - it's like rigidbody interpolation doesn't work 100%, which seems unlikely - but you can clean this up by separating the model from the rigidbody, and making the model track the rigidbody with aggressive lateUpdate lerping/damping (ie, small timestep so the model lagging behind the collider is not noticable)

Gist

Unity Helper for Physic Functions. GitHub Gist: instantly share code, notes, and snippets.

Unity Physics can be hard. And it is even harder, if you do not know the basic principles. I will show you the core basics in rigidbodies, to give you a kickstart in this topic. In this tree part tutorial you will definitely understand things like .AddForce, .AddTorque and .CenterOfMass way better than through the unity manuals and offical tutor...

▶ Play video
dreamy pollen
#

Lots of useful info here

robust grove
#

(I'm guessing this is where I would put this but) I'm wanting to have the falling speed be a set number so that this doesn't happen, but I don't want to affect the jump height/speed , does anyone know how to do this?

#

(so clipping like this doesn't happen)

uneven shore
#

but generally speaking you can:

  • change the the gravity/mass dynamically, increasing it when the player is falling rather than jumping.
  • calculate the initial gravity scale and jump force based on the desired falling speed and jump height/speed.
robust grove
uneven shore
#

option #1 then 🙂 cool

robust grove
stuck bay
#

You will get everything you need on this channel

gray trout
#

How can I make a Gameobject ignore the player ( and the player ignores it )
but still check if they collided?

daring furnace
#

look into Triggers Vs Colliders

twin dove
#

how would one use a blender-made armature to implement ragdoll physics

timid dove
amber crater
#

When would I use a Rigidbody2D. Because if I create a 2D Objects -> Physics -> Static Sprite, it puts a rigidbody on it, but if these are removed it still works the same.

torn nymph
#

VR: I have kinematic rigidbody on hands with capsule colliders for fingers, and floating objects in scene with non-kinematic rigidbody. I can push the floaters with my hands, but no force is applied, meaning they stop instantly when I stop pushing, whereas if I push a floater into another, they bounce apart and float off. Do I have a setting to change to get the kinematic body to impart force/velocity on the non-kinematic body?

timid dove
amber crater
#

thanks

timid dove
#

otherwise your kinematic body is basically teleporting around each frame and there's no actual force/velocity to impart

#

either that or detect the collision and apply forces of your own based on your own reckoning of the motion of the hands

sleek meteor
#

hey im kinda retarded and i have a question, but i made a diagram

#

i want to turn a quat into a byte that just gives a quadrant level detail of rotationals

#

can someone tell me if i'm 1) retarded, 2) on the right track 3) can't make diagrams for shit, 4) there is already a built in unity for this or i guess to just f myself

#

the reason behind this is to not sully my beatiful netcode but avoid spinny boi gimble lock situation

#

which doesn't happen often at all, but can

timid dove
# sleek meteor

Not really understanding what you are looking for with this diagram/explanation.
Also have no idea what you've tried already so no comment on the "on the right track" bit

sleek meteor
#

i haven't tried much of anything, besides imaginging some bloated not very eloquent code to figure out the quadrant i'm in, so to speak

#

again i apologize for being this level tarded and also terrible with various forms of microsoft paint products

#

its like, in my beautiful netcode that took so long to make i lost sight of my game, i'm syncing 15 rigs in an active ragdoll game flat hierarcy no animations in 33 bbytes and 1 bit

timid dove
sleek meteor
#

but i do occasionaly get a gimble lockish situation

timid dove
#

ar ethey suppsoed to be 90 degree slices?

sleek meteor
#

they are vectors going from each corner

#

diagnoally

timid dove
#

and the rest of the words in the diagram seem like nonsense to me. Hip? each flag w/nef togg 0000. is no lean?

#

?

sleek meteor
#

top to bottom, like, south west bottom to north east top

#

etc

#

actually it hought about it, and i think 11 11 11 11 would be standing stright up

#

for my convention

timid dove
#

huh

sleek meteor
#

i'm gonna use [flags] on a byte

sleek meteor
#

so not going to evaluate it to a decimal, just as flags at each bit position

timid dove
#

that was very confusing

#

but still don't see what that has to do with the quadrants 🤔

sleek meteor
#

so i have access to my hip's full transform right

#

but i want to send it over the innerwebs, and my glorious netcode bein 33 bytes and a bit, i can't have anymore than another byte before it hurts my feelings and my pride

#

and i really don't need more than like, a very crude way to represnt which sort of, very general way the hip may be tiltted

timid dove
#

if you just want to encode which quadrant you're in (4 possibilities) that's only 2 bits of data

#

unless I'm missing something

sleek meteor
#

unlabaled are the bottom 4

#

becaus i could be inmverted

#

upside down

#

breakdancing, etc

timid dove
#

I don't understand

sleek meteor
#

on head

timid dove
#

wait.. sorta understand maybe>?

#

But then that's 3 bits

#

8 possibilities

sleek meteor
#

but if i want to lean forward

#

thats a north east positive, and a north west positive

#

thats why if i use a byte with [flags] i can get more than just the vertices

#

leaning backwards would be southeast positive and southwest positive

timid dove
#

Maybe it would have made more sense if you explained from the start what you're trying to do

sleek meteor
#

leaning left, rightside up would be northeast positive and southeast positive

timid dove
#

You're trying to represent... the leaning of your character?

sleek meteor
#

i'm tryin fam, lol

#

i really am

#

yea

#

everything is relative to hip, its an active ragdoll all rigs, no animations, flat hierachy

timid dove
#

because you just kinda started with "how do I turn a quaternion into a quadrant of rotationals"

sleek meteor
#

yea, i' am so like, dumb in this area, its hard for me to even phrase the question

#

which is why i wanted to apologize in advance for being tarded

#

but if you stick with me, i believe in my heart of hearts i can convey this crakced out idea

#

i have my transform, and access to all its transformy things, quat, eulers etc, and if i can figure out how to translate that as per bad diagram into a byte, i know how to use this byte on the receiving end

#

the level of detail here would be like, a D-pad with diaganols

#

but 2 of them, on top of each other

#

maybe i could just use 1 and then have a bit for if i'm upside down..

#

i donno, this is kinda hurtin because i still dont even think unity could possibly give me all thse frames with all those update loops

#

i have a programming background, not a graphic design one, if that is'nt painfully obvious

#

without flags, that would be 9 bits,

#

which is absolutely unacceptable

#

i need 8, there's gotta be a way to do this with flags

#

but more importantly, theres gotta be some kinda unity functionality to handle the majority of this mathfs

timid dove
#

use "Unity's transformy things" as the presentation layer

sleek meteor
#

no no no, everythign works fine as is without any rotaional daata of this form

#

i occassionally get on rare occassions spinny boi gimble lock

timid dove
#

then there's no need to convert from a quaternion into such a form

sleek meteor
#

i figure i could sanity check on remote players side to correct this

timid dove
#

you said there's no animations right?

sleek meteor
#

code driven

#

it takes a byte

#

everything is done via forces applied to rigs

#

this is the entirity of my receiving end netcode for all 15 rigs

#

    this.netRecPlayerRotationX = (float)stream.ReceiveNext();
                this.netRecPlayerRotationY = (float)stream.ReceiveNext();
                this.netRecPlayerPosition = (Vector3)stream.ReceiveNext();
                this.netRecPlayerVector = (Vector3)stream.ReceiveNext();
                this.netRecPlayerAnimationState = (MovementStates)stream.ReceiveNext();
                this.netRecIsADS = (bool)stream.ReceiveNext();
#

33 bytes and a bit

#

movementstate is my flags thing i use to pick my code driven animation forces

#

its a byte tho

#

rotation x and y are camera/gun angle

#

playerposition vector3 is hip

#

playervector vector3 is the current inputs direction of travel so to speak

#

and then the others, yea, i could fit fkin ads into the animation state but i need it with that data

#

then to adjust each rig, its all relative to the hip + my animation state based stuff like this ```cs

                            Vector3 position = this.PlayerHip.position;
            Vector3 vector = Vector3.Lerp(position, this.netRecPlayerPosition, Time.deltaTime * 1f);
            Vector3 vector2 = Vector3.Lerp(position, this.netRecPlayerPosition, Time.deltaTime * 1f);
            Vector3 deltaVector = new Vector3(vector.x, vector2.y, vector.z) - position;
            foreach (Rigidbody riggy in rigidbodyHolder.rigs)
            {
                riggy.MovePosition(riggy.position + deltaVector);
            }```
#

which is called from a fixed update loop after checking the player is not local and therefore neesd to be updated via the netcoders

#

it works really well, except sometimes, homey be spinnin a bit, and doesn't udnerstand concept of upside down, which can cause more spiny boi

#

so i i have that byte, i can kinda just invert some things to get him approximately oriented

#

ignore the redundant lerpin btw

#

since you (usually) walk but not always, y lerps dif than x/z

#

....normalized signed values of cross product of netRecPlayerPosition against netRecPlayerInputVector maybe?

#

i've got several, would you like networked or not networked

#

and by me, i mean, poached open sauce github repo's that i forked or at least starred

#

even got 3d networked among us , i hear that's what the cool kids are playing these days

#

programming is just a symptom of a failure to master good googling or lack of trying, i mean, as per rules of internet if you can think of it , it must exist

analog sinew
#

what

tiny notch
# sleek meteor

Ok so I know nothing about netcode, but as I understand it you are trying to encode rotation information into a single byte?
Your diagram is wrong. Eg, if SW = 00 and NE = 00, then:
If SE = XY and NW = XY, then you have no lean, for all of XY = 00, 01, 10, and 11, they cancel each other out and information is lost

If we have an origin at the centre of the cube:
Now draw a vector out to the midpoint of each edge, the centre of each face, and each corner of the cube. That is 26 possible directions the character could be leaning in. If we also care about the rotation of the character at each value of lean (ie, a character standing straight up should still be able toface in different directions), then we could also get away with having 8 rotation values at each point the character can lean towards, since 26 * 8 = 208 bits, which is less than the information is one byte = 256 bits. So for one byte, 0000 0000, I would use the first 5 elements to represent lean, the last 3 to represent rotation

I think you cannot represent lean by using angles, since you will need 2 rotation axes with 8 bits of information each to represent 8 possible values in each of the two axes, which would require 64 bits to represent lean, and 64 * 8 = 512, which is > the 256 available. The reason for the information loss is that, for example if we are using conventional Unity x and y euler angles, then at x = 000, or x = 100 (directly up or directly down) the y value is irrelevant.

I think the easiest option is actually just to use those 26 possible lean directions as possible values in an enum. So in the attached image, there are 6 possible intersections at the centre of each face, give each of these its own specific value of the enum. Do the same for all 8 directions pointing to each corner, and all 8 pointing to the middle of an edge (they should all be a part of the same 5 element bitfield). Then do a switch on the bitfield on the client side to find out which direction you are leaning

tiny notch
#

So in case thats not clear, diagonally upwards elements would continue from the previous values like so:

#

so say you had a bitfield 0010 1011.
Create a copy of this bitfield client side and zero out the last 3 bits in this copy, so you now have 0010 1000.
Now do a switch on this enum. You should find that your lean value = horizontally left, from the first image.
Now work out your rotation at that lean from the last 3 bits of the original bitfield

fierce parrot
#

Im hoping someone could possibly help me with the set up of my chain for my lantern... you will see from the video i am getting rather strange results!!
sorry if posting a video isnt allowed (i will remove it if so!)

If anyone can spot what could be the problem, any help is appreciated

halcyon ruin
#

Is there a way to use RaycastAll and hit the same collider without having to store the hit.points and raycast all over again?

timid dove
waxen phoenix
#

Hi, I've been looking at previous replies here and in the forums but Im unsure, is there a single working networked physics solution for Unity apart from quantum/photon (which is out of the question because of price)?

torn nymph
#

Not sure what your price constraints are, but you can also check out NormalVR

waxen phoenix
waxen phoenix
timid dove
#

yes

#

if you set things up right

waxen phoenix
# timid dove yes

thanks. weird, I've used mirror for a couple of years and never actually noticed that networked rigidbody component, is it recent? it shows up under experimental on git

timid dove
#

no idea.

#

AFAIK Mirror has always had a solution for rigidbodies

waxen phoenix
#

damn. thanks for pointing it out. feel kinda dumb rn not gonna lie

sleek meteor
# tiny notch Ok so I know nothing about netcode, but as I understand it you are trying to enc...

shifty pete! thank you for looking into my hard for me at least to articulate question so thoroughly!!!!!!! This is extremely helpful, it's actually above and beyond my issue! I think you have thoroughly enough answered this that i can work on it, but to be clear, I do already send 2 floats worth of rotation (camera x/y), however, the point of my theoretical extra byte is basically simply to stop occassional, at least what i believe to be a form of gimble lock, where other players appear to spin, and additionally, if do to physics interactions in the level, and the player becomes somewhat or all the way inverted (updside down) they again either spin or glitch a bit beyond what makes it a fair fight, and this can be exploited. This is why i was looking for this kinda, lowest level of detail rotational system, just to perform a sanity check on remote clients so i can either course correct or proactively check somehow to avoid the gimble lock (if it even is that, i think it is, but i'm not an expert on the subject)

torn creek
#

ok so i have some code to keep an object rotated towards an aimed at point, however it doesnt consistently work - it will work most of the time until it gets bumped massively in which it stops working

(blue is where im aiming / where it should point, red is where it is pointing)

ive tried variants using vectors / quaternions, with changes and they all seem to have the same issue

for the video linked, currently using a vector method (below) and it doesnt work

Vector3 dir = (pos - transform.position).normalized;
float aimPct = force * stats["aimStrength"] * selfWJ.moveResist * Time.fixedDeltaTime;
transform.forward = Vector3.Lerp(transform.forward, dir, aimPct);
#

ive also tried this

Vector3 dir = (pos - selfWJ.rb.position).normalized;
Quaternion dirRot = Quaternion.LookRotation(dir, Vector3.up);
float aimPct = force * stats["aimStrength"] * selfWJ.moveResist * Time.fixedDeltaTime;
selfWJ.rb.rotation = Quaternion.Lerp(selfWJ.rb.rotation, dirRot, aimPct);

and this

Vector3 dir = (pos - transform.position).normalized;
Vector3 dirRight = Vector3.Cross(Vector3.up, dir);
Vector3 dirUp = Vector3.Cross(dirRight, dir) * -1;
Quaternion dirRot = Quaternion.LookRotation(dir, dirUp);
float aimPct = force * stats["aimStrength"] * selfWJ.moveResist * Time.fixedDeltaTime;
transform.rotation = Quaternion.Lerp(transform.rotation, dirRot, aimPct);

to no avail

however, if i directly set the rotation rather than lerp it works

this also happens if i use RotateTowards rather than lerp

shadow seal
torn creek
#

what do you mean thats what lerp is used for, for going smoothly between 2 vectors by an amount
im just using some extra stat variables along with time.deltaTime

shadow seal
#

@torn creekas long as dirRot is the correct rotation, there is really only 1 option

#

unless....

#

you're using a non-kinematic rigidbody?

torn creek
#

isKinematic is set to false

#

when i set it to true i believe it was working temporarily but havent managed to get that to work again since

shadow seal
#

I think the rigidbody and the lerp are conflicting

torn creek
#

but obviously i want it to be non kinematic as i want physics on it

#

thats what i thought, however i am using the rigidbody.transform / rotation

#

i did wonder if it was that tho

shadow seal
#

uhhh

#

try increasing the angular drag or something

torn creek
#

increasing?

shadow seal
#

yeah

#

so that the rigidbody will stop rotating faster

torn creek
#

oh that actually worked

shadow seal
#

good

#

the same sort of error happens when you pair a rigidbody with a nevmesh agent

torn creek
#

so is it because the transform and the rigidbody rotation are going against each other?

shadow seal
#

well

torn creek
#

so angular momentum stops the rigidbody somewhat?

shadow seal
#

it has angular momentum or whatever

#

(haven't taken a physics class in 4 years)

shadow seal
#

and the lerp is doing nothing to slow down that angular momentum

#

so you have 2 counteracting forces

torn creek
#

is there anyway to rotate it so that it takes into account this momentum?

#

that does make sense

shadow seal
#

is there anything wrong with keeping the angular drag the way it is

#

besides that, you would have to manually mess with the rigidbody's velocity/angular velocity through code

torn creek
#

honestly no and it doesnt feel too hacky
however it would feel cleaner if there was some function on the rigidbody that rotates it to a certain amount and updates angular momentum accordingly

shadow seal
#

which you shouldn't do unless you know what you're doing

shadow seal
#

have a flag that sets to true on OnCollisionEnter

#

nvm that's redundant

torn creek
#

yeah thats seems a bit sketchy too

shadow seal
#

in OnCollisionExit, set a flag to true, and have a void (that executes if the flag is true) that progressivly lowers the angular velocity of the object to 0

#

idk

torn creek
#

it does make sense that having no angular drag means the angular momentum never goes away meaning its affecting its rotation constantly
i think just changing that value is a fine enough fix

#

that all does make sense thanks for the help

shadow seal
#

rad

#

your mechanics look cool btw

torn creek
#

yeah very early days but got big plans

shadow seal
#

ugh

torn creek
#

not that itll ever come in fruition

#

but yknow

shadow seal
#

100% of my projects

torn creek
#

never hurts to be ambitious and mess around

shadow seal
#

dude it ABSOLUTELY hurts to be ambitious

torn creek
#

i mean in a real project yeah

#

but for just messing around making little game tests

shadow seal
#

I agree

torn creek
#

as a way of learning weird issues and how to fix them i mean

#

scope creep n that

shadow seal
#

scope is my number 1 enemy

#

anyway, clogging up the physics channel

empty flare
#

Yeah I have a question… so I’m making a 2D game.. I’m trying to make it so that when the object hits the ground it stops.. I have a box collider 2D for the background and have a polygon collider 2D for my object but the object is not stopping where I set the collider for the background… can someone help?

rigid reef
empty flare
#

It’s kinda hard to show you what I mean…

#

I have the green box set for where the ground is

rigid reef
#

Send a screenshot with the colliders selected

empty flare
#

You talking about the one for the background or the object

rigid reef
#

both

empty flare
#

Can I stream my screen to you it would be a ton easier

rigid reef
#

send the screenshot with the inspector in it

#

ok

limpid vigil
#

I have a mesh collider related question, is there a way to prevent "degeneration" of the mesh when i toggle convex? i dont think im describing this well enough because i can't find anything online..

#

example, convex enabled on left, right is the mesh used to make the collider

#

it has 24 verts total, so its not too complex

#

its clearly doable, a demo of an asset has this working

shadow seal
#

dumb question, are you sure you have the right mesh on the meshcollider component?

limpid vigil
#

fair question though, let me have a check

#

yes it is the correct mesh, the same one i exported with the rendered mesh

#

its not named c_meshname though (i have no reason to think this is anything more than a way to keep things tidy)

shadow seal
#

I have never personally seen that before

#

maybe someone else could help

limpid vigil
#

this has always been its behavior for me since i started messing with unity 2 months ago 😅

#

thanks anyway spooky ghost friend!

#

but now...i think maybe something in my project settings or preferences could be the culprit, if this isnt the case for others

desert timber
# limpid vigil I have a mesh collider related question, is there a way to prevent "degeneration...

I would also love to find a better resource explaining the Convex mesh collider option. I have a hunch that It does more than simply... "decimate" (I think is what the graphic artists call the reduction of surface polygons) the mesh.

But, to directly answer your question, no I don't think we can stop this. The popular workaround I've seen is to create two separate convex mesh colliders, then attach them to this game object.

I don't actually know what's more performant: 2 (3, 4, ... ?) smaller convex mesh colliders, or one large non-convex collider.

limpid vigil
#

i do wonder how that bottle asset up there managed to do it though, i think i'll just ask the creator if nothing comes up

desert timber
#

hm, decimate is probably the wrong idea, since if we were to click the decimate button in Blender on this bottle, it would preserve the narrow neck

limpid vigil
#

decimate with very very low values probably, in any case, its a bit of a black box it seems

#

i couldnt find anything on preferences that relates to the extent of the decimation/degeneration unfortunately

lapis vault
#

If i have a physics object that is shaped like a bowl, and it has multiple balls inside which are also physics objects. They all have different mass, so can i somehow calculate how much that bowl weights with multiple balls inside without referencing each balls rb mass? I know this is a confusing question but i don't know how else i could describe that.

timid dove
bold yew
#

Hnng.
I have a tank (collider is a box, so the tank part doesn't really matter) that just won't rotate right.
It's being dragged around by a navmesh agent and has a rigidbody restricted on rotations Y and positions X and Z
When I hit a bump or something, the thing ramps up on one side properly but then falls down back flat really slowly. This is even worse with procedural terrain, and it's impossible to keep the vehicle upright with this issue. What could be causing a rigidbody to fall back flat so slowly? Both drag and angular drag are 0.

I'll post an example.

#

Hmm. It appears the issue is related to the fact positions X, Z are constrained

bold yew
#

Yeah I just jury rigged it by applying a downforce on the tank because why not

timid dove
#

what was the mass of your tank?

#

Real tanks are very heavy. If you left the mass at 1 then I imagine it would be quite bouncy indeed

desert timber
#

What's the difference between terrain and large mesh colliders? I know terrain has many extra features, but for simple use, are the two somewhat interchangeable?

I know that if we have a lot of rigid bodies moving around, then mesh colliders should be avoided at all costs. I assume the same goes for terrain as well?

Is there disadvantage to using a large mesh object as terrain? As far as I can tell, it seems fine.

I've read that there's a 65k vert limit to mesh objects in Unity, but it seems that large fbx are being split up on import somehow under the hood, I guess? For example, I was thinking about chopping up this model into 10 pieces (<65k vert each), but it seems that I don't need to?

timid dove
desert timber
#

if it's just the player for collisions, is there anything to worry about?

timid dove
#

I couldn't tell ya. Test it out on your target hardware and see.

vagrant helm
#

I made a four arm avatar and I added rigid and fixed joint to the secondary arm, anyways, they dont rotate

#

they keep the T pose

timid dove
red umbra
#

i am a begginer creator and for some reason whenever i move my character in my game and when it collides with another object my character randomly pushes back in the opposite direction without me pressing w, a, s or d

#

does anyone know why this is happening

#

?

timid dove
#

You're probably not moving your character in a physics-friendly way, so your character is tunelling partially inside obstacles, and the physics engine is pushing it back out

waxen phoenix
desert timber
#

it seems fine afaict, but I'm still suspicious, haha

waxen phoenix
#

lod changes with distance too

desert timber
#

hmm, partial culling too?, a single mesh might insist on being rendered all at once?

waxen phoenix
#

as for physics, I am unaware of any terrain specific optimizations so my guess is it would be the same

desert timber
#

it's sounding like bearable drawbacks under certain circumstances

limpid vigil
#

i figured out the degeneration issue, disabling this allowed it to work! @desert timber @shadow seal thanks for the assistance regardless guys

desert timber
limpid vigil
#

you're welcome, least i could do since its so esoteric

#

i dont know what "fast midphase" actually refers to, but the rest seems self explanatory, if difficult to actually determine if it was processed

desert timber
#

hmm, docs say that it's faster for runtime creation, but might not work on some systems

limpid vigil
#

i see, im not really sure if the advantages outweigh the extremely inaccurate collisions however 😅

shadow seal
#

midphase

#

@limpid vigil I think that it's for high poly meshes

#

in your case, though, you custom modeled the collider?

limpid vigil
#

in any case, i did not want them degenerated since they're already "light"

split mauve
#

Hey guys, looking to read up on character movement with a rigidbody, I'd like my guy to push things around naturally
Is there any existing knowedge?

limpid vigil
devout token
split mauve
#

Thanks dude

lilac garden
#

I'm having a raycast issue. I'm currently behind a wall that is made of 1x1x1 BoxColliders, all placed by 1 unit to the top or to the sides or bottom. But there are areas behind that wall that the raycast doesn't fire TRUE for a hit to that layer. Raycasts are firing at 1 Y unit

#

This ray is returning false (cast is made from the player)

wide nebula
#

Its probably is due to the seam between the colliders and you firing the ray exactly at it. Can you offset the raycast a bit as a quick test to see if it fixes the issue?

lilac garden
#

I already added .01f to Y End Point's Direction. But I'll move it also.

timid dove
lilac garden
#

the other is in the right side hair corner

timid dove
#

Still confused. Is this a ray fired from the camera? Or somewhere else?

wide nebula
#

You're shooting this ray from the camera to the marked point?

timid dove
#

What are the starting and end points of this ray?

lilac garden
#

I was actually shooting from the player looking for a true hit to layer mask "wall, ground or cutout sprits"

timid dove
#

Ok so the bushes are made of a bunch of box colliders?

lilac garden
#

yes

timid dove
#

It may jsut be you're running into the issue where raycasts in 2D don't hit colliders that they originate inside

lilac garden
#

oh so the ray stops at first hit?

timid dove
#

that too yes

#

but not what I was describing

lilac garden
#

it's 3d colliders tho

wide nebula
#

But if the source of the raycast is inside that collider.

lilac garden
#

project demands 3d colliders, in case you are wondering

wide nebula
#

Try it from the camera, and layermask it against the wall objects just to be safe about it.

lilac garden
#

alright, I will invert the raycast. Thanks

timid dove
stuck bay
#

1 minute I need to load different project

#

@vast meadow

#

here it is

vast meadow
#

tysm

stuck bay
#

Car rigidbody mass 600

vast meadow
#

oh mine is about 5000 but since the friction values are ratios (i think) then it shouldnt matter

lilac garden
# wide nebula Try it from the camera, and layermask it against the wall objects just to be saf...

Still returning at least 1 false when fully behind wall, sometimes 2 falses, depending on the area.

public LayerMask groundMask, wallMask, cutOutMask;

private void Start()
{
    layers = groundMask | wallMask | cutOutMask;
}

private void Update()
{
    float dist = Mathf.Abs(Vector3.Distance(camRaycast.position, transform.position))*2;
    print("LeftRaycast = " + Physics.Raycast(camRaycast.position - new Vector3(0, .1f, 0), leftRaycast.position, dist, layers) + " -----     RightRaycast = " + Physics.Raycast(camRaycast.position - new Vector3(0, .1f, 0), rightRaycast.position, dist, layers));
}
wide nebula
#

To actually raycast from the camera (not it's position). You would have to convert the point to shoot at into screen space and then use ScreenPointToRay.

timid dove
#

(assuming camRaycast is the camera transform?)

lilac garden
timid dove
#

either way - LineCast if you want to specify two positions

#

RayCast if you want to specify a starting position, a direction, and a length

stuck bay
#

[Physics 2D] Any idea on how to simulate a rope, made of a bunch of little squares, attached on both ends to a different object, without letting the cells (squares) of the rope go 'crazy' (get away from the rope in a considerable way) whenever a hit from an object with 100m/s occurs? Each rope cell is attached to the next one through a HingeJoint2D.

#

Is there any other approach which could be taken for simulating a 2d rope, which could resist such forces?

lilac garden
desert timber
devout token
desert timber
#

end of the day, just try and see I guess

#

the profiler is happy but I'm worried I'm missing something

devout token
#

You know what to look into if it's not working right on low spec tests

desert timber
#

umm, not a single clue

#

I'm using URP and would like to support most laptops

#

I only have my desktop for testing

devout token
#

I mean the stuff we've been talking about, tiling, selective unloading and whatnot

desert timber
#

ohh, no I'm not sure how I would apply these concepts to a single large mesh

#

Blender would be needed to chop it up, I think, to enable selective loading/unloading

devout token
#

Just converting it to unity's terrain system would allow its optimizations to take effect, you have many different options

#

Even if you don't know how to exactly do these things, you know wht to search for

desert timber
#

that would destroy the UVs, though?

#

maybe... these things look very time consuming, I might just remove the mesh if performance becomes a problem

devout token
#

Or test it with a low end pc, see if optimization is worth the trouble or even necessary

#

If you want an open world game that works on basic laptops, you're going to have to learn to do some tricks, I can tell you that much

desert timber
#

Ohh, sorry I guess I have multiple questions running. I know anything expansive needs to be handled with a lot of thought..

#

but, for "player enter a shop" settings, I'm wondering if I can transition to a scene with one of these very high vertex models

#

really amazed (... skeptical) that Unity can handle 1M vertices with little more than drag and drop

#

I can almost go nearly to 10M vertices before lag pushes my desktop under 60fps

#

so I guess that means models with 1M will be fine in most cases

summer fog
#

can I put multiple colliders onto a single game object

#

I'm reading a bunch of conflicting things on the forums

#

I'm trying to figure out the most efficient way of attaching many simple colliders to a single game object

fading tundra
#

You can but you will have problems if they intersect.

#

Also, there could be inaccurate collisions. It would be better, I think, to parent empties to your object and attach the colliders to those instead.

summer fog
#

they won't intersect

#

they are all static

#

relative to that game object

fading tundra
#

I don't know how Unity's internal code works, but anything that is just GetComponent<Collider>() is going to return the first collider only.

summer fog
#

or any of those APIs

#

as they aren't very fast

#

I do use them occasionally

#

but mostly in init methods

fading tundra
#

Then you should be fine. Each of the colliders will fire events normally.

timid dove
#

it's not going to affect the performance of the physics simulation one way or the other afaik

#

it just makes things more confusing when it comes to collision callback functions

summer fog
#

gotcha

sleek meteor
north palm
#

is there any way to stop rigidbodies giving energy/movement to other rigidbodies on impacts. I have a rigidbody bullet colliding with a player but the bullet is pushing the player and i would prefer if it didnt. anything i can do about this?

stuck bay
north palm
#

ok thankyou

gilded panther
#

Yoh,

I was looking for a good way to make something, simple...

My player can move and push all environment objects (affected by gravity with rigidbody).

My question is : How can I remove the fact that the player is slowed down or stopped by these objects?

(I'm not english, if you need more explaination, tell me)

#

Basically, all objects is affected by the movement of the player, by pushing, but, my player can't be affected by the movement of these objects.

desert timber
gilded panther
hybrid cave
#

Correct me if I'm wrong: If a collider collides, it sets the velocity of its parent to 0, doesn't it?

summer fog
#

it tries to follow the laws of physics

#

it might stop

#

might slow down

#

might bounce

#

might just knock the other object out of the way and keep going

hybrid cave
#

Understood, thanks! I need to rethink my logic for moving the character around, because if the player "runs" into a wall and tries to climb it at the same time, the vertical velocity is blocked as well

tiny notch
# sleek meteor oh , one thing i think i either didn't mention or explain right is i was plannin...

If you aren't doing rotation with the final 3 bits of the bitfield, then yeah you will have just enough bits to do it this way. Personally I wouldn't though. Flags are used for data that can coexist in multiple states simultaneously, whereas in your case, your character can only have one direction. Using flags will mean you will need lots of checks for how to interpret different combinations of flags. Also, you will be wasting information, since this will require all 8 bits, when you could get away with using 5.

wraith junco
#

Anyone know how to access/modify the random physx seed value assosciated with a unity project?

#

I'm trying to get the same calculations between multiple projects

desert timber
wraith junco
# desert timber that sounds like something that doesn't exist

Whenever I make two different unity projects with the same exact scene and do a rigidbody cube drop, the cube ends up in a different position.

If I create a new project, clone it, and THEN build the scene with the cube drop, it ends up in the same position

#

so something is going on

wraith junco
#

I'm aware of what determinism is

#

physx is supposed to be deterministic on the same architecture anyways

#

I'm doing it on the same machine at the same time

#

there's forum posts on the unity forum about people talking about a "physx seed" that aids in determinism across multiple projects

#

I'm just trying to figure out how to access it

desert timber
#

I guess a seed could still exist, but I'm not seeing anything for that in here (at a glance at least)

#

have you enabled a fixed timestep?

rose rapids
sleek meteor
#

ill probably do some bitmasking in the csaes of the switch

rose rapids
grand forum
#

I need help with an issue im having

#

in wich my character keeps flicking when he hits a wall

#

it doesnt stop the movement

#

it keeps trying to get through the wall, and the sprite looks weird needless to say

timid dove
#

the solution is to move your character in a physics-friendly way

grand forum
#

would u be kind to check my code out and help me improve it?

#

i got in a youtube tutorial

#

its probrably not the most optmized

#

probably*

somber wagon
#

Is it possible to check if a point is inside a concave mesh collider?

somber wagon
#

3d

timid dove
# somber wagon 3d

Try this:

bool IsPointInsideCollider(Collider c, Vector3 point) {
  return c.ClosestPoint(point) == point;
}```
somber wagon
#

That would only work with convex mesh colliders wouldn't it?

#

Because concave mesh colliders are empty inside

timid dove
#

try it

somber wagon
real finch
livid token
#

Hello everyone, i am trying to make my tank move up the ramp but my player/collider is catching on the ramp despite the physics material being friction 0

#

I tried using wheel colliders but they are buggy as shit and kept giving me weird physics errors and forcing my entire gameobject to spin into the ether

#

I am using rb.AddForce(targetPosition, ForceMode.VelocityChange); to apply movment

#

the mass of my player is "1" if that influences anything

livid token
#

I got it fixed!

#

The solution was to make the physics material friction 0 (which i already had) and to make the Friction Combine to Multiply too!

#

smooth as butter now 😄

wraith junco
#

so yeah that's pretty normal behaviour

frank shore
#

the setting is in rigidbody called slop limit

wraith junco
#

@frank shorethats not a rigidbody. that's a character controller.

frank shore
#

oh sorry

nocturne rapids
#

Where can I ask a question about prefabs D:

desert wave
nocturne rapids
#

Yeah I went ahead and threw my question in there I appreciate it

weary moon
#

has anyone used Rigidbody.SweepTest before?

#

im getting weird behaviour with it and id like some help

#

i figured out the reason behind the behaviour and its stupid

#

for some reason SweepTest doesnt report an intersection if the rigidbody is already colliding with the collider that the sweeptest is intersecting

sleek meteor
livid token
#

yeah try setting bounce to 0 and bounce to multiply

#

@real finch

sleek meteor
#

hey prolly want the other way tho, its the bounce threshold velocity,k so maybe set it to like 5 or 10 or something

#

also feel like char controller with rig when dont want need rig and if do want it kinematic

dusky acorn
#

Hi, I have a question. I'm making a flight sim game and I'm triging to make a flight phisics correctly. I'm not sure how to do this, so for the moment I'm just adding a rigidbody.addforce to object, and the problem is that, when I'm changing the object rotation, for example it's going forward, while it's turned 45 deagres to right. How can fix that? Or maybe I should do fly mechanics in other way?

timid dove
wind meadow
#

hi so i tried to utilize physics2d ignorelayer collision function between two layers but they still continue to collide. Are there other steps i need to take in order to allow two layers to ignore collisions?

timid dove
#

You can also just do it from project settings without any code

#

Make sure the colliders are on the layers you are setting up to not collide

wind meadow
#

yeah got it fixed. turns out i had my character on the wrong layer

livid token
#

:p

worn meadow
#

we need to see your code

shadow seal
#

@real finchI have that exact issue

real finch
#

I fixed it it was A result of poorly written code

tight canyon
#

my character's floating when i do the running animation, and when i stop running, it falls down

timid dove
stuck bay
#

So im really new at game engines. I started on the unity FPS tutorial. I started adding my own bits to the map, but something didn't work...

dreamy pollen
#

What is the Rigidbody2D equivalent of Forcemode.VelocityChange?

cobalt sequoia
#

I need collisions between 2 generated meshes. i'm currently using meshcolliders but these will only collide if convex is enabled which isnt an option i could however make it up of individual colliders but i need 4k of these to represent a single one of my current meshcolliders at worst case so it seems like a bad idea to add them as individual components. is there any better solutions?

hearty lava
#

Hello everyone! I have a rigged character, that uses Jasony's gang beast physics. When it falls down, the model becomes invisible.

#

I didn't find any other channel to ask for help about this topic

#

It appears to disappear once the model actually moves

#

(the character falls down)

#

nevermind fixed it

last stump
#

Hello! I have an empty GameObject that has a specific amount (doesn't matter how many) of small rectangle GameObjects as children. Each of these rectangles has a BoxCollider2D component. When my player collides with one of them, for some reason it detects a collision between the lpayer and the parent, not the children. Any way I can change it?

timid dove
#

There's different fields for different things

#

Read the docs carefully

wraith junco
#

you'll also need to post the code if you want help

#

there's really no other way anyone is going to help you

last stump
bold yew
#

Bouncy abrams 4 life

hearty lava
#

Hey everyone! I have an active ragdoll npc working. I am animating it by changing the target rotation in an animation. How should I move it? I tried setting target velocity to 0,0,20 in the root configurable joint, but it didn't affect it at.
I did change the z-drive value to a high number, still no effect.
and the docs don't have any information/examples on that

fringe heron
#

Hello, can You tell me why the charactercontroller is always above ground, when I directly adjust it, it jumps so there is a gap between foots and ground

#

Oh, skin width helped me I think..

royal walrus
#

Would it be possible to have two rigidbodies, one for a vehicle and one for a passenger, such that the passenger would be able to roam around on top of the vehicle while the vehicle is in motion (i.e. accelerating, decelerating and turning)?

desert timber
royal walrus
#

For instance, if you use a simple capsule to represent your player, this won't translate well since your shoes have a larger surface area than a single point (assuming the capsule is upright)

#

Therefore, turns that a player with shoes can withstand might be too dificult for a capsule

desert timber
echo prism
#

Hi. Can I get yaw, pitch and roll from a normal vector?(or 2 vectors)

copper garnet
#

Hello, i want to make a game where you can build stuff like in minecraft but with physics, you can place blocks onto each other, and if the creation isnt placed to the ground, it have rigidbody physics. To do that i create empty gameobject with rigidbody and set all gameobject cubes as its child, but i also want to add bearings so you would be able to rotate stuff but i don't want to use unity joints because they are wobbly and i want them to be rock solid no matter what. Is there a way to do it?

sleek meteor
#

localrotation?

hearty lava
#

idk if that's what you want

#

but they aren't wobbly

copper garnet
copper garnet
stuck bay
stuck bay
#

show actual camera code

dim flint
#

Hi
I wanted to know if someone could help me with a problem that I have.
I have a player with a rigid body and other objects with their own collider and when pressing shift the speed of the player increases a little. The problem is that when they increase their speed, they begin to go through the colliders of the objects that surround them.
I don't know if someone can give me a guide to solve this problem

timid dove
#

If you're using transform.position = or transform.Translate() that is not a physics-friendly way

devout token
#

The planet is jittering, or skipping in relation to world as it moves, while the ship isn't
Both are about as simple RBs as one can make with no code that moves them, besides AddForce on the ship

#

Oh, heh
Seems I found the issue before I finished typing up the description of it

#

The planet had Transform.LookAt towards the camera in LateUpdate, which one would reason only affects rotation, but apparently it has an effect on the position as well

#

Or enough of an effect that it breaks interpolation

foggy socket
#

Hey, guys. If I want to apply torque to a rigidbody, it's moment of inertia is defined by collider, that is linked to it?

shrewd shoal
#

is there anyway to only allow an object to move on a certain local axis, ive tried using rigidbody constraints to lock it on the other 2 and those work globally, so it only will go one way and not depend on the orientation of the parent

#

but i want it to depend on the orientation of the parent and only not be locked on the local z

timid dove
#

the planes can be defined by the parent object's local axes

#

gonna be kinda rough with a Rigidbody though

#

also possible to just zero out the relevant 2 components of the object's localPosition

#

or - reset those two components to whatever the desired non-zero value is

shrewd shoal
#

thanks, somehow didnt think i could just set the localposition x and y to zero

#

but works out fine

#

have a good one

prime niche
#

Hey everyone,
Sooo.. beginner question😂
I made this very basic and probably bad movement script for a character in a top down 2d game (Script: https://imgur.com/a/iV8DVaM). It's not the best piece of code but it worked, UNTIL it hit object colliders. For some reason, when i let go of the movement button, it keeps moving along the wall rather than stopping like the code says. (Here is the issue in action: https://imgur.com/a/8ZMjssb)

#

Is the problem in my code? or is it something else in the rigidbody settings or something?
Any help would be appreciated

timid dove
#

for example you only zero out vertical velocity when releasing the W key

prime niche
#

Is there a way I could turn that off?

timid dove
#

I mean you could simplify this whole thing to about 3 or 4 lines of code

#
void Update() {
  float horizontal = Input.GetAxisRaw("Horizontal");
  float vertical = Input.GetAxisRaw("Vertical");

  playerBody.velocity = new Vector2(horizontal, vertical) * moveSpeed;
}```
prime niche
#

Hmm yeah that's much better than my garbage code😂

#

Just that i haven't used those before

Thanks

desert wave
verbal karma
#

yeah just change new Vector2(horizontal, vertical) to new Vector2(horizontal, vertical).normalized

safe flare
#

how do I get my objects to slide? They kind of just tumble. I'm trying to make a conveyor belt and that's not really what I'm aiming for.

tender gulch
#

Reduce the friction of the ground collider material.@safe flare

prime rain
#

WHYYYY

brittle spoke
#

I'm having an issue with updating mesh colliders for procedurally generated planets.
Currently what I do is bake the physics mesh on a different thread and once that is done assign the updated mesh to the mesh collider. However, the mesh collider does not recognize the fact that the mesh has already been baked and it goes and bakes it once more. ( This is the same if I bake it in the main thread, so threading isn't the problem here ).
I have searched online and only found one forum thread covering this where the issue was marked as fixed in the 2019 - 2020 versions of Unity, but it seems clear that the issue still exists ( At least in the 2021 version of Unity which I am using ).
There was a suggested workaround that I tested to no avail. The workaround was this: "Do not reuse the Mesh instance for now. Every time you bake, that should be a new Mesh instance.". I could have misunderstood this as there were no code examples of the workaround I could find.
I'll post the code responsible for setting the mesh of the mesh collider shortly

#
   thisThread = new Thread(() => Physics.BakeMesh(getMesh.GetInstanceID(), false));
   thisThread.Start();

   while (thisThread.IsAlive)
   {
       yield return null;
   }

   faceData.face.collider.sharedMesh = getMesh;
#

Of course, this code is within a coroutine as to not slow down the main thread while it waits for the other one to finish the work

brittle spoke
#

Alright, I have found a fix. You need to set it inside FixedUpdate, for some reason that fixes the double bake

zealous mason
#

Hello everyone, i would just like to ask, what are the physics that can be apply for Unity? So far the only I’ve seen would be water, vehicles, airplane and i was wondering if there would be more?

timid dove
zealous mason
#

I see, thanks alot @timid dove

sleek meteor
#

have you sen the grabit script

lilac garden
#
private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Trap"/* && !other.gameObject.GetComponent<Trap>().hasTriggeredOnce*/)
        {
            other.gameObject.GetComponent<Trap>().hasTriggeredOnce = true;
            other.gameObject.SetActive(false);
            other.GetComponent<BoxCollider>().enabled = false;
            print("HELLO WORLD");
        }
    }

Why does it trigger 5 times with enabled = false; and trigger only once when SetActive(false)?

proper galleon
# prime rain WHYYYY

KEKW How realistic are you going
pepedetect don't forget about the torque being applied by the main rotor on the fuselage

#

KEKW does your game allow for autorotation

timid dove
safe flare
#

why are collider types still being drawn regardless if I have them selected or not?

stuck bay
#

trying to emulate gravity. Using this formula.

But this dosent work. on the bottom right. how do i fix it.

Error: "Operator '/' cannot be applied to operands of type 'int' and 'GameObject'"

verbal karma
#

now tell me how you're planning to divide the integer 1 by the gameobject a

#

@stuck bay

stuck bay
#

Legit

verbal karma
#

bruh

stuck bay
#

but i have no other way of fixing this. moon wont orbit this planet

#

it will only orbit the sun

safe flare
#

can't divide a game object by a number that doesn't make sense

#

probably some value attached to the game object

stuck bay
#

yeah thats what i was thinking. but i thought that i was being dumb. But i was the opposite.

safe flare
#

maybe a.transform.forward or a.transform.up or a.transform.right

verbal karma
#

None of those make sense either

#

In this context

safe flare
#

well they want it to orbit a planet and they have it looking at the planet now they just need to move it in a direction no?

stuck bay
#

I Did instead ((Gravity * m2) / r);

#

but

#

That dosent work either. just orbits one object

safe flare
#

oof feel like an idiot rn i forgot that's a vector3

verbal karma
#

Lol

stuck bay
#

im like confused on why they say that 1 / gameobject is a "fix"

#

i thought their trolling but its a legitmate tutorial

verbal karma
#

They cant have done 1 / a without getting the same error as you in any known universe

verbal karma
#

Cool

safe flare
warped slate
#

I am making a 2D game and I want to set the default physics offset to as low as possible so I can make colliders the same size as the sprite without the gap in between colliders. The problem is, turning the default physics offset to as low as possible causes the collisions to be bouncy and dampened, removing any rigid collisions, even if the rigidbody is set to continuous. I noticed that changing the physics simulation mode from FixedUpdate to Update fixes the problem, bringing back rigid collisions. However, I don't want to simulate physics in Update because the framerate can cause inconsistencies in the physics simulation. Is there any way for me to set the default physics offset to 0.0001 while still maintaining rigid collisions and using FixedUpdate?

warped slate
rapid wadi
#

Can anyone help me understand how I can generalize this to 3D? It is finding the value of gravity g and initial velocity v_0 based on the inputs peak projectile height h lateral velocity v_x and the horizontal distance to the peak of the jump x_h

#

my main headache is trying to calculate g since squaring a Vector is undefined.

timid dove
rapid wadi
#

That is what I thought too. Perhaps I am not thinking of it correctly but if I do that I get a gravity vector with 0 doward force

#

or y component is 0

timid dove
#

?

#

what are you trying to calculate here

#

that system of equations can be used to calculate a bunch of things:

  • initial velocity
  • peak height
  • etc..
  • result distance
rapid wadi
#

So in 2D the goal is to be able to say, "I want my jump to be h high, and cover 2x_h ground" So you input those values along with the lateral traveling speed v_x and you get a gravity value g and initial velocity V_0 that gives you the exact parabola properties you wanted.

Or so that is what it says in the GDC video for this slide
https://www.youtube.com/watch?v=hG9SzQxaCm8

GDC

In this 2016 GDC talk, Minor Key Games' Kyle Pittman shows how to construct natural-feeling jump trajectories from designer-friendly input like desired height and distance, modeled programmatically using one of a few available integration methods.

GDC talks cover a range of developmental topics including game design, programming, audio, visual ...

▶ Play video
#

but in 2d V_x is scalar, so I am stuck

timid dove
#

and then you'r ebasically solving for v0 and vx

#

Which probably goes something like:

  • ok with gravity G, I need to jump with initial velocity of what to get to that desired height?
#

Then if you know the desired height you can calculate how much time you'll spend in the air

#

and then you just use that amount of time to calculate the horizontal velocity you need to move the desired distance along the ground in that time

#

though that system of equations seems poised to calculate it the other way around 😛

rapid wadi
#

Yea I am confused. Thanks for the help, I need some time to think and let this simmer in my smooth brain.

#

Maybe I am misunderstanding and misrepresenting the video. Because he is an accomplished professional developer. And I tested out his jump in a free game he provided and it feels really good.

#

Gonna rewatch it a few more times.

timid dove
#

TBF I did not watch the video

rapid wadi
#

So in the end I replaced V_x with the scalar lateral speed in the direction of the jump and it worked perfectly. The jump has all the properties you give as input.

#

I need to derive the equations by hand to see if V_x was actually meant to be a scalar the whole time.

static venture
#

I have a spring joint but it wiggles too much before reaching resting point, how can i reduce this wiggling?

tender gulch
static venture
#

Damper i presume

desert timber
rapid wadi
#

Thank you. I see that now. Explains all my confusion.

#

I have a question about how to manage multiple sources of velocities and accelerations. Any help would be appreciated.

I do want to preface this with, I know I should just let Unity Physics handle all this and I should just use the CharacterController, and I agree. This is more for me to learn than something I would put into an actual game.

How do you handle multiple velocities and accelerations?

For example, I have an input event from wasd keys that moves the character in each respective direction. To accomplish this I do the usual

var moveVel = new Vector3(input.x, 0, input.y) * runSpeed;

Then I set my final velocity to moveVel

Great it works. But now I want to add a jump velocity?

I don't want to set my final velocity to moveVel every frame because then it overwrites my jumpVelocity that only gets added a single frame.

So what do I do here? I know theres like a hacky solution like

var moveVel = new Vector3(input.x, finalVelocity.y, input.y) * runSpeed;

This prevents my lateral moving velocities from overwriting my constantly changing (due to gravity and random jump forces) vertical velocities.

But this is only a bandaid fix that breaks the moment any more velocities are introduced (like random velocities from speed zones or projectiles hitting you, etc).

Does anyone have an resources that explain how to properly manage velocities acting on a body that can easily scale to handle any number of outside forces?

desert timber
rapid wadi
#

I see. I think I am having trouble explaining what I don't understand.

I think what I am confused about is how the velocities are managed frame to frame.

for example

frame 1

  • d is pressed. Velocity = (0,0, runspeed)
    frame 2
  • d is being held Velocity = (0,0, runspeed) // notice that we dont add the velocity since that would double the speed so we overwrite the velocity
    frame 3
  • spacebar is pressed Velocity += (0, jumpForce, 0) // this is the only frame where the velocity is correct
    frame 4
  • d is still being held Velocity = (0,0, runspeed) // jump is overwritten since we are not just tacking on the constant velocity

I could of course just not replace the y component when getting move inputs but then what happens when I want to add horizontal movements from other sources. How can I manage those outside of the movement input

frame 1

  • d is pressed. Velocity = (0,0, runspeed)
    frame 2
  • d is being held Velocity = (0,0, runspeed)
    frame 3
  • speed boost applied Velocity += (0,0, boost acceleration) // this is the only frame where the velocity is correct
    frame 4
  • d is still being held Velocity = (0,0, runspeed) // speed boost gets over written
#

is user input a special case? Do I only add the velocity onPress then subtract it onRelease? But then that makes it so I cant introduce any friction because the velocity is only ever applied once and adding friciton would reduce it to 0. I am just super confused on how all these sources of forces are managed

specifically sources where they add constant velocity, like mvoe inputs

desert timber
#

Hm, overwriting is simply a coding mistake, just add them all together for a final velocity. An acceleration vector is needed to keep track velocity over time

#

I think the tricky thing is that for the motion you're looking for, you can't be using v=runspeed, you would want v+=acceleration*dt each frame

rapid wadi
#

Sorry, I was trying to simplify my explanation of the issue I am having so it wouldnt be so long.

I am using the integration from that popular blog post, forgot the name

newVelocity = (Velocity + 0.5f * Acceleration * deltaTime) * deltaTime;
Velocity += Acceleration * deltaTime;

I understand the relationship of acc and velocity. Acc is the rate at which velocity changes.

I think I just suck at explain my issue. Tomorrow I will make a concrete and detailed example and post here again.

desert timber
#

It can be hard to ask the right questions when we're learning something new

rapid wadi
#

Too true, and it is giving me a headache. I don't even understand what I don't understand. Thanks for taking the time to help anyways. I will think this over and have a more precise example tomorrow.

dull adder
#

how do I make my player not slide on the ground?

#

I made this material and gave it to the ground

#

but its still sliding

dull adder
#

fixed.

vagrant helm
#

Im trying to add cloth but constraints wont show up

dapper wigeon
#

ROTATE PLAYER TOWARDS TARGET USING PHYSICS?
I'm trying to make a RB rotate towards a target, using physics only, but its much harder than I imagined.

1: MUST use .AddTorque()! NOT .MoveTowards(), transform.RotateAround() etc.
2: The RB has a "maxForce" that it can use when applying torque - either at max or less (never more)
3: Function should make RB use max allowed torque to reach point where it needs to break with max torque, to reach target perfectly.

DOES ANYONE HAVE GOOD RESOURCES FOR THIS?

All related forum posts just repeats the same misunderstandings like:

  • "Why do you have to use physics for this" (I just do, ok.)
  • "You can create a PID controller for this!" (No, since we know how Unity works, we can actually calculate this perfectly instead, which is what I want.)
  • Also many answers forget that there's a "maxForce" that can be applied.
supple sparrow
#

I would also use a PID controller ( I remember I did a looong time ago and it worked - just need to be patient to tweak values). I don't understand your argument when you say:

No, since we know how Unity works, we can actually calculate this perfectly instead, which is what I want

dapper wigeon
#

Well a PID controller is used in environments where variables are not 100% measurable

supple sparrow
#

THis sounds to me like you could run your own equation and appy the correct rotation to the transform yourself, so you wouldnt need physics in that case

dapper wigeon
#

But since Unity is a program, we can know how is works. How it applies accel, velo, drag etc.

#

I WANT PHSYICS OMG xD

#

It amazes me that I cant find a solution online - seems like noone wants to touch physics when it comes to rotation, only movement

supple sparrow
#

Well it's messy especially in 3D with gimbal-lock, quaternions, and such

#

Anyway I don't understand how you want to achieve your goal so not sure i can help here

dapper wigeon
#

Its 2D, so that makes it tons easier

supple sparrow
#

Sure

dapper wigeon
#

Only need for 1 direction

#

Its primarily a physics problem (the only thing you need to know about Unity, is how it applies these things). So most programmers just resort to "how can we make it function as fast as possible", without caring about the fact that I want it done with physics.

merry narwhal
#

I got a question i cant get cloth to work in unity 2019.4.29f1 anyone know a solution for this?

dull adder
#

this.

vagrant helm
#

Im using cloth, I dont know why but the skirt grows

wary ferry
#

Anyone know why my rear tires (using Wheel Colliders) keep sliding (like turning into a drift) whenever I make a turn?

shadow seal
#

either way, I kinda like it like that

spice kite
#

Dumb question here. I forgot how to edit the walkable area / navmesh thing. How do I change it?

It's the green lines btw

wary ferry
wary ferry
spice kite
hexed horizon
#

Does anyone know if there is a way to toggle eDISABLE_SIMULATION on a physx colliders, which nvidia recommends for objects that are not affected by simulation/forces/etc? I have a use case where I have many active physx scenes, most of them have non-movable objects and I am still seeing significant CPU time just calling scene.GetPhysicsScene().Simulate(Time.fixedDeltaTime); on these otherwise inactive scenes.

spice kite
delicate fox
spice kite
#

Ah okay, I know how to edit a box collider as well haha but not mesh

delicate fox
spice kite
#

That's fine. Just need to find someone who knows how to edit a Mesh Collider

spice kite
#

Anyone?

desert timber
# spice kite Anyone?

umm, sounds not possible to me, but I'm not sure. Unless you wanna' head over into blender to edit vertices? But, if you're talking about ProBuilder, then you can edit the vertices then apply the new mesh collider

spice kite
#

So your telling me that if I use ProBuilder, then I can extend the mesh?

#

Which one?

spice kite
desert timber
#

any shape created with probuilder can be edited

spice kite
#

But the mesh is FBX which isn't ProBuilder?

desert timber
#

Yep, you'd have to export that into Blender, then reimport. I think the pros block out an approximate shape with tools like probuilder for colliders since mesh colliders can cause performance problems

spice kite
#

You mean import to Blender then export into ProBuilder?

desert timber
#

umm, export from unity, import into blender, export from blender 😛 .. if you want to edit vertices of a mesh, yeah

spice kite
#

Okay one sec

graceful grove
#

Hello,
I'm already desperate of this situation and even after 5 hours I can't think of any solution so maybe someone more experienced can advise.
In the picture I have two colliders set on one object, boxCollider is a trigger and capCollider is not. The problem is that the trigger is supposed to give me the information in the script that I have landed on the ground, this works for me but it absolutely does not stop on the capCollider and the object ends up under the texture (maybe somewhere in the middle, it's random), as soon as I remove the trigger on the boxCollider it stops on the capCollider without any problem but it doesn't work passing it to the script (I have to have the boxCollider because of the different rotation). And the bottom left picture is exactly the same only with MeshCollider where everything worked as it should, unfortunately I had to redo the model because of the texturing and because of that meshCollider can't be applied (it does something that absolutely can't be used). My question is, what should I do about it? I really don't know what to do anymore.

spice kite
desert timber
spice kite
#

Ah okay, the model is FBX so I'll go to Blender

#

But what file does ProBuilder take?

desert timber
#

probuilder would be a completely separate idea

spice kite
#

No like to import to Probuilder

desert timber
#

probuilder creates mesh from scratch

spice kite
#

Because I'm not sure on how to edit meshes in Blender

spice kite
#

I don't have it

#

Wait... is it the New Poly Shape?

desert timber
#

umm, it sounds like you might need to find a tutorial to follow, it should be available

spice kite
#

This?

desert timber
#

i think so? hard to tell

spice kite
#

It's the Poly Shape

desert timber
#

yeah that's one option you can use

#

I'm sorry I can't provide help at this level of detail, look for a ProBuilder tutorial, hundreds out there

spice kite
#

The plane is a bit weird because it's on the floor but you get the idea

desert timber
#

it's a lot of work though

spice kite
#

True but that's for a later day

#

So the yellow lines. What are they and how to edit them?

desert timber
#

light probes 😛

spice kite
#

Meaning?

desert timber
#

meaning you've dived straight into the deep end without following a tutorial 😛

spice kite
#

Sorry, my friend helped me with this build and I don't know half of what he added

#

The mesh and light probes he added which is why I don't know what they are haha

desert timber
#

well you can google about light probes I'm sure

spice kite
#

Oh, it is just in the name

#

Okay so why can't I move into a certain area

#

The white cyclinder gets stuck at the door

#

It's this bit

desert timber
#

ok, well let me know if you need tutorial recommendations

spice kite
desert timber
#

Brackeys' is my goto, but sometimes his videos are too short, give this one a try maybe? https://www.youtube.com/watch?v=CHV1ymlw-P8

Learn how to create AI pathfinding using the Unity NavMesh components!
This video is sponsored by Unity.
● Watch on Unity's website: https://goo.gl/jUsU8D

● Example project: https://github.com/Brackeys/NavMesh-Tutorial

♥ Support Brackeys on Patreon: http://patreon.com/brackeys/

·································································...

▶ Play video
spice kite
#

Thanks

spice kite
#

How do I get the doorway to be baked?

#

@desert timber

desert timber
#

What is baking?

desert timber
#

Learn how to update your NavMesh at runtime!
This video is sponsored by Unity.
Watch on Unity's website: https://goo.gl/rz5mda

● Example project: https://github.com/Brackeys/NavMesh-Tutorial

♥ Support Brackeys on Patreon: http://patreon.com/brackeys/

····················································································

♥ Donat...

▶ Play video
#

If you've watched both of these, then you know more than me. I haven't played much with navmesh yet

green cobalt
#
ntdll!NtWaitForMultipleObjects+0x14
KERNELBASE!WaitForMultipleObjectsEx+0xfe
KERNELBASE!WaitForMultipleObjects+0xe
UnityPlayer!winutils::ExternalCrashHandler::HandleCrash+0x26d
UnityPlayer!winutils::ExternalCrashHandler::HandleCrash+0x22
UnityPlayer!winutils::ProcessInternalCrash+0x118
KERNELBASE!UnhandledExceptionFilter+0x1bc
ntdll!RtlUserThreadStart$filt$0+0xaa
ntdll!_C_specific_handler+0x96
ntdll!RtlpExecuteHandlerForException+0xf
ntdll!RtlDispatchException+0x40f
ntdll!KiUserExceptionDispatch+0x2e
UnityPlayer!DynamicHeapAllocator::Allocate+0x299
UnityPlayer!DualThreadAllocator<DynamicHeapAllocator>::Allocate+0x9a
UnityPlayer!MemoryManager::Allocate+0x8c
UnityPlayer!malloc_internal+0x5c
UnityPlayer!NovodexAllocator::allocate+0x31
UnityPlayer!physx::shdfnd::BroadcastingAllocator::allocate+0x3c
UnityPlayer!physx::shdfnd::ReflectionAllocator<physx::Gu::AABBTreeBuildNode * __ptr64>::allocate+0x70
UnityPlayer!physx::shdfnd::Array<physx::Gu::AABBTreeBuildNode * __ptr64,physx::shdfnd::ReflectionAllocator<physx::Gu::AABBTreeBuildNode * __ptr64> >::growAndPushBack+0x48
UnityPlayer!incrementalBuildHierarchy+0x6a
UnityPlayer!physx::Sq::AABBTree::progressiveBuild+0x18f
UnityPlayer!physx::Sq::AABBPruner::buildStep+0x128
UnityPlayer!physx::Sq::SceneQueryManager::afterSync+0x79
UnityPlayer!physx::NpScene::fetchResultsPostContactCallbacks+0x68
UnityPlayer!physx::NpScene::fetchResults+0xcf
UnityPlayer!PhysicsManager::Simulate+0xa49
UnityPlayer!ExecutePlayerLoop+0x57
UnityPlayer!ExecutePlayerLoop+0xf3
UnityPlayer!PlayerLoop+0x10c
UnityPlayer!PerformMainLoop+0x1be
UnityPlayer!MainMessageLoop+0xda
UnityPlayer!UnityMainImpl+0xca1
UnityPlayer!UnityMain+0xb
RustDedicated!__scrt_common_main_seh+0x106
kernel32!BaseThreadInitThunk+0x14
ntdll!RtlUserThreadStart+0x21

Anyone seen this crash before? Getting it randomly but frequently

tight canyon
#

hello

#

i have an issue regarding my character floating on a terrain while he's running

#

and when i stop, it falls down

#

these are my current settings as of now

tight canyon
stuck bay
#

how do you get tree colliders that aren't just capsules?

#

I'm using poly trees but don't want to use capsules for collision

verbal karma
#

mesh collider

stuck bay
#

I've added one to the prefab but it doesn't collide in game

verbal karma
#

it should, try making it convex perhaps?

#

PhysX sometimes doesn't like non-convex mesh colliders

stuck bay
#

Neither convex or concave work

#

it does show this though

#

also apparently concave mesh colliders don't interact with rigid bodies (my player). it's low poly though so I might just be able to make 4 different meshes and mesh colliders for the prefab

stuck bay
#

Hmm yeah so mesh collider isn't working but capsule collider is

#

Both by player mesh and the tree mesh are set to convex

#

Enable terrain colliders is ticked in my terrain collider

#

Why tf is this not working

#

Guys

#

Someone help lmfao

lofty coral
#

does anybody know how to make a moving rigidbody not go through colliders? the rigidbody has collision detection on continueos

dull adder
#

OOOO

#

I FOUND OUT HOW TO MAKE SIMPLE WATER!

#

it looks like this.

#

all you need is circles and particles.

#

but its a little laggy

#

it works as a slime-like substance too

#

it is connected together with particles.

timid dove
lofty coral
#

i fixed it but thanks

#

i have an other question tho

lofty coral
#

if you know what i mean

timid dove
#

transform.forward (or transform.right for 2D) is generally the "forward" direction for your object.

lofty coral
#

wait imma send my "Move" function

#

void Move()
{
float xMove = Input.GetAxisRaw("Horizontal");
float zMove = Input.GetAxisRaw("Vertical");

    rb.velocity = new Vector3(xMove, rb.velocity.y, zMove).normalized * walkSpeed;
    
    
}
#

that works but i need it to move by the direction im facing and not in a set direction

#

its a 3d project btw

timid dove
#

Like I said

#

transform.forward

lofty coral
#

but if i do transform.forward then the collider skips the physics of collision

timid dove
#

No it doesn't

#

Use transform.forward to set the velocity

#

It only skips physics if you set transform.position

lofty coral
#

could you edit the script i sent and put in what you mean pls

timid dove
#

Or use transform.Translate

#

No that's your job

lofty coral
#

i dont get it though

#

where should i put the transform.forward

timid dove
#

you said you want to use it for the velocity

lofty coral
#

yes

timid dove
#

So what's the confusion

lofty coral
#

i want to use rb.velocity but where in that method do i put the transform.forward

timid dove
#

assign it to rb.velocity of course

#

It's just a direction Vector3

lofty coral
#

like this or what do you mean : rb.velocity = new Vector3(xMove, rb.velocity.y, zMove, transform.forward)

timid dove
#

Wat

lofty coral
#

im new to this

#

idk how to do this

timid dove
#

You should read the documentation for things to see what parameters they take

#

For example the Vector3 constructor only takes 3 parameters

lofty coral
#

ok

thin hamlet
#

Is there a way how I could calculate how much velocity is being added to the rigidbody from 1 particular source? I have multiple .AddForce() sources to the rigidbody and I would like to limit one of those sources to only be able to add up to X velocity, no matter the global velocity (So lets say current velocity is 0, so I can add up to max 0 + X velocity, if current velocity is 100, then I can add up to 100 + X velocity, etc.)

flint apex
#

alr yeah i quit

spice kite
#

@desert timber Do you know how to add a point in ProBuilder?

I've got a point (TOP LEFT) but I was wondering how to create a point below it. I can't find a way to do it

desert timber
#

that would be called splitting an edge, and is not available in Unity, it's also unrelated to #⚛️┃physics

#

(probuilder does a lot more than I realized, actually... wow)

desert timber
spice kite
#

Alt + S doesn't do anything

desert timber
thin hamlet
desert timber
#

I would imagine two monobehavior classes, eg, Train and Passenger, where the Passenger keeps reference to the Train and adjusts for changes in relative velocity each step

#

maybe tricky though, since things can move in random orders and potentially cause collisions

tight canyon
#

hello

#

can someone help me

#

the model's floating whenever i do an animation

dry harness
#

Gravity not working at all

tough path
#

I'm creating a custom 3D player controller and I'm using a box collider as the collider (idk if this is relevant, but the box collider will always have an identity rotation). I'm trying to create custom physics simulations for the player using Physics.ComputePenetration, Physics.BoxCastNonAlloc, etc. but how would I actually put the results of those functions into use?

kind obsidian
#

I have a player, and it has gun recoil that pushes the player back, or exploding crates.

I use rb.AddForce. The issue is, I need to have a high Linear Drag so that when the player's input stops, the player doesn't carry on walking "as if it's walking on ice". Unfortunately, this causes the side-effect that recoil and when nearby crates explodes, the player almost "teleports" and the movement is "rough". I want recoil / explosions to be slippery, but player movement not slippery. So, in other words, high linear drag for player movement, but low drag for recoil and explosions.

I heard that using the mix of rb.velocity and rb.AddForce can cause issues?

One solution could be that everytime there is recoil or crate explode, I would have to do if (recoil > 0) rb.AddForce(recoil * recoilDirection); recoil -= Time.deltaTime or calling some coroutine? Is that kinda approach the right one?

#

There are a few odd solutions like using coroutine on rb.AddForce/velocity. I have to be careful not to make it interfere with physics calculations in future e.g. slippery floor etc.

kind obsidian
#

Actually for now, I'll compromise on tweaking the Linear Drag to try make it high enough for player movement, but low enough to make the recoil good looking and not changing too much.

Edit: I think this is the best way to avoid complications with interfering with built-in Physics calculations. I tried it and it is good enough.

empty kernel
#

any reason my 2drigidbody is acting weird like this? it keeps literally intersecting with a box collider at high velocities

#

still processing, so resolution might be ugly but does anyone know why this might be happening?

sonic geyser
zinc sleet
#

@tough cloak hi

tough cloak
#

Hi

zinc sleet
#

one sec

tough cloak
#

👍

zinc sleet
#

can i stream my screen to u

tough cloak
#

Sure

#

I'll be muted tho

zinc sleet
#

np

vestal olive
thin hamlet
#

I've been stuck at the problem with rigidbody movement for quite some time, basically what I want is to limit only player's movement from his input and not any external forces. I've been googling a lot lot and all solutions I've found consisted of:

  1. You can't set rigidbody velocity with RB.velocity because you will overwrite any other external forces added to the object
  2. If you want to limit maximum possible velocity from .AddForce() you need to clamp RB.velocity
    Which is kind of frustrating because this 2 solutions contradict one another. Another solutions I've found were based on only adding force when player's velocity is under maximum speed, this solution isn't very appealing because the forces applied to gameobject will be inconstistent because you can always go sligthy above limit.

I've tried to implement or find multiple solutions and the best movement I was able to achieve was with this type of limitting maximum speed: Vector3 velocityChange = targetVelocity - RB.velocity; (source: http://wiki.unity3d.com/index.php/RigidbodyFPSWalker). But the problem again is that when I add external force, it will get immediately reduced because of this line.

Could anyone help me with this problem? I don't want realistic physics behavior, I'm currently working on prop style game mechanic, that means player can transform into many objects in the game which are being controlled by Rigidbody and I want this movement to be smooth (from player's input) and at the same moment I want to be able to add any external forces, e.g. jump pad, to the object without this impulse force being overwritten by player's movement from his input.

timid dove
#

I've done this before. Basically, if you're going at max speed or greater, you'd project your potential AddForce vector along the current velocity direction, and subtract that bit from the potential force vector

#

in plan english think of it like: "remove the component of force that is in the direction of current motion, leaving any other force alone"

#

so you would be able to add a force opposing the current velocity but not add more velocity in the direction you're already going too fast

#

and you wouldn't be touching velocity directly so no worries about interfering with velocity you picked up from external sources (knockback effects, etc)

thin hamlet
#

I'm going to look into this, thank you