#⚛️┃physics

1 messages · Page 1 of 1 (latest)

chilly maple
#

ok

#

i got this problem

#

u see, i am setting the velocity of a 2d rigidbody to a value such as 2 or 3.

#

but for some reason, it is not moving

#

wait

#

lemme try something

chilly maple
#

ok

#

i think the problem lied with the tilemap2d collider

#

i changed it to a temporary Polygon collideer

#

and it is working

spiral escarp
#

is there any real downside of changing springjoint's spring value to 0 instead of destroying it every time?

timid dove
wispy patrol
#

Hi there, I have a car that stutters and I tried adding SmoothDamp and it still stutters but the game's environment looks smoother

last veldt
wispy patrol
wispy patrol
#

Yeaaaaaa

#

Thank you Pickle

last veldt
#

yeah np

#

Does anyone know how to link up physics so they aren't reliant on the framerate my projectiles keep passing through my enemies because they are too fast?

wispy patrol
#

I have this problem when my car goes too fast and hits the ground. Seems to be a mass issue.

last veldt
#

I've changed the mass it didnt make a difference what I'm betting on is there is a line of code that I just don't know that syncs physics to the world at this point I might just add a raycast instead though

tall monolith
#

how can i detect when 2 object collide with each other with a strong force

nocturne lagoon
#

Hello again! im not sure where exactly to put it but: (posted it also in the general code just in case it belongs there)
Im trying to find this green vector and Ive got three points A, B, C. How can i find that vector in unity?

viral ginkgo
#
var projection = Vector3.Project(C - A, B - A);
var green = C - (projection + A);

@nocturne lagoon

#

Plug in 0,0,0 for A to see it better if you want.
The above one is orientation/position independent.

#

if A is origin:

var projection = Vector3.Project(C, B);
var green = C - projection;
vital goblet
#

Hi there! I'm fairly new to unity overall, I was trying to make car suspensions through rigidbody and raycasting

Rigidbody.AddForceAtPosition(ray.direction * -SuspensionForce, hit.point);

this is what I'm using to add the force to the rigidbody, but even by adding Drag this keeps happening, any idea on how to fix it?

timid dove
vital goblet
#

then I should just be able to apply the inverted force that is being casted on the individual raycast to get a stable suspension, right?

#

sorry if my english isn't great, I'm not that good at explaining my ideas

viral ginkgo
#

@vital goblet your force should be proportional to distance offset the suspension is stretching

#

if its stretching 10cm, lets say the force is 10 units

#

if it stretches 20 cm, the force should be 20 units

#

and you should also do dampening on the axis where movement happens

#

To prevent oscillation

#

if the strech is happening at 1cm per frame, you apply 1 unit of force in the opposing direction
if the strech is happening at 2cm per frame, you apply 2 unit of force in the opposing direction

#

thats basic pd control

vital goblet
#

yup that was exactly what I was thinking of doing, not too familiar with C# or raycasts in general, I'll see what I can do

#

thank you

viral ginkgo
#

np

quartz wyvern
#

is it possible to move a rigidbody but keep it bound to a navmesh some how

#

was a bit weird using it with navmesh agent so that wasn't an option

wide nebula
#

I think Tunic uses that technique. You can sample a mavmesh without actually moving on it. So you would have to check if a future position of the RB would be on the mavmesh or not.

quartz wyvern
#

right so i dont need a navmeshagent i just need to query the navmesh surface

#

i'll give it a try

quartz wyvern
#

oh nice that worked better than i expected thanks!

last veldt
last veldt
tall monolith
quartz wyvern
#

if you set detectCollisions = false whilst inside of a trigger collider, will this trigger a OnTriggerExit

#

trying to debug right now and can't figure out why its not triggering

last veldt
last veldt
quartz wyvern
#

maybe

#

ill do some tests later

last veldt
#

yeah hope it helps

split dew
#

would this be the right channel for a question regarding particle systems?

#

If so, I am basically trying to stop particles from clipping through walls. Played with collisions already but there are still these weird lines

uncut cliff
#

hi. so im using navmesh agent and area is baked too. and upon start, agent just moves slightly up. i want it to stay on ground. any ideas?

winter jetty
#

@uncut cliff it could be the parent objects origin being down below the visible 3D objects. unparent all the children components, click <- persp on the top right of scene and click one of the side axis to ensure the origin of the parent object is on the ground maybe.

uncut cliff
winter jetty
#

hmm not sure but there are a good few threads on it. try this pasted thing

You should change inside the Nav Mesh Agent Compomenet the agent size. You should use it to build a collider around the player. Adjust the radius so that your player fits inside and adjust the height in such a way that it contains your whole player. If the collider is not centered, use the offset to centre it.
uncut cliff
#

i edited the base offset again and again till it is now on the ground

#

not sure if its the best practice

quartz wyvern
#

im having annoying issues with my RB movement, im moving it with move position and its really jittery some times - other times its buttery smooth... not sure why or how to solve it... this is how i move it:

        void MoveTowards(in Vector3 dir)
        {
            float speed = 2f; //test value
            var pos = _rb.position + dir * Time.fixedDeltaTime * speed;
            if (NavMesh.SamplePosition(pos, out var hit, _navmeshThreshold, NavMesh.AllAreas)) //dont walk outside navmesh area
            {
                var point = hit.position;
                _rb.MovePosition(point);
            }
        }
        void RotateTowards(in Vector3 dir)
        {
            var look = Quaternion.LookRotation(dir, Vector3.up);
            var rot = Quaternion.Slerp(_rb.rotation, look, Time.fixedDeltaTime * _rotSpeed);
            _rb.MoveRotation(rot);
        }

im not using kinematic as i still want collisions - what could the jittery movement be caused by ?

#

i call these functions in fixed update

#

you can see it here after i hit the box my movement is jittery

#

although the gif fps makes it a little tricky to see

#

my rb is not kinematic

viral ginkgo
#

@quartz wyvern Hmm, try locking y rotation maybe?

quartz wyvern
#

oh that seemed to have fixed it

viral ginkgo
#

Also set the rb.velocity to zero in fixedupdate

quartz wyvern
#

thought i needed that unlocked due to using move rotation

viral ginkgo
#

nope

quartz wyvern
#

so the locked rotations only apply specifically to applied forces not move functions

viral ginkgo
#

Your issue probably accumulating rotational velocity

#

While you are using the rotation sets

quartz wyvern
#

yeh the jittery stopped if i stopped moving for a second or two

viral ginkgo
#

Maybe it was messing with interpolation

#

But I was suspecting linear velocity really

quartz wyvern
#

i'll zero them out every frame just to be sure

green needle
#

when some can help, i have a simple player and a simple room, when ever i go to a corner the and try to essentaly push my self out, my charicter starts rotating slightly to a side on the y axis and it dosent stop the slight rotation, how could i fix this

#

nvm i fixed it

rare relic
#

How would I go about attaching a cloth between two points? I.e. like below, where the one end of the rope is statically attached to the hull, whilst the other would move along with the rotation of the center boom?

untold tundra
#

Hi idk if this problem goes here but i model a character in blender rigged and animated with mixamo and when i upload it in unity collider is too small or in a different place like this.

#

I checked the origin point rotation and scale in blender they all seem okay any idea why this is happening ?

sudden hinge
#

Hello, I'm trying to do a stack of coins but they don't stop jittering.
There is no special code attached, and we tried to use rb.interpolate but nothing change, any ideas please ?

timid dove
#

interpolation doesn't do anything to the physics simulation

#

try playing with things like Sleep Threshold, Default Contact Offset, etc... in the physics settings

leaden sigil
#

Okay so i made this rope.

#

But as you see it bends a bit.

#

If you know what i mean by that, The different rope pieces keep overlapping each other, they have an collider tho.

#

Anyone know how to solve this?

#

Like this:

stuck bay
#

Now I got the Kart to stop rotating on its OWN axis but now its rotating with the axis of the Sphere collider like a Ferris Wheel

unique cave
warm pilot
#

does an ArticulationBody contain JointDrive s?

#

it seems likely but it's not explicit in the documentation.

wraith junco
#

So in my raycast wheels I'm trying to implement a good simple working sideways friction. I've tried using the dot product to simply counter the gravity and I've even tried simply countering the true velocity of the wheels (F = MA) but the car still inches slowly downward when sideways on a slope

#

What am I missing?

#

Both of the above methods work if there's no suspension on the car, it's like there's some force being applied by the suspension that I'm missing

wraith junco
#
SidewaysDrag = transform.InverseTransformDirection(SidewaysDrag);
SidewaysDrag.y = 0;
SidewaysDrag.z = 0;
SidewaysDrag = transform.TransformDirection(SidewaysDrag);

// Acceleration = velocity / time
// Force = mass * acceleration
_Rigidbody.AddForceAtPosition((-SidewaysDrag / Time.fixedDeltaTime) * (_Rigidbody.mass / 4), _RaycastHit.point);```
#

This is the sideways friction code running on all of the wheels. The car ever so slightly is gliding down the slope. If I apply this to the ACTUAL car rigidbody's velocity (without the .mass / 4, just * .mass) it works fine and cancels out all sideways velocity

#

I'm just curious as to why it's not doing what I want

plucky coyote
#

Hey guys is there a job system version of physics.checksphere? i know there is raycastcommand for the raycast but i'd like to know if there is a checksphere version (not spherecast but checksphere)

somber kestrel
#

can I have multiple colliders (triggers on) on a GameObject and depending on what collider has been distracted process a certain method?

#

I know I could have children with their own Rigidbodies and Colliders but how would I catch their collisions in the parent script then?

#

my case is

I have a location and many interactive spots where you get different possibilities so I have to know from 1 script what collider the player stepped in

#

death/ warning message/ teleport back .. colliders

timid dove
somber kestrel
#

damn that's bad

#

I wanted to avoid scripts piling up

timid dove
#

it's one extra script

somber kestrel
#

but you tell me the opposite

timid dove
#

¯_(ツ)_/¯

somber kestrel
#

one? hm yeah maybe

timid dove
#

Most mature projects have hundreds/thousands of scripts.

#

As long as the game is not trivial

somber kestrel
#

hm unluckily I have never seen a large game made in unity from the editor perspective

#

anyway still I'd like to

lofty coyote
# wraith junco I'm just curious as to why it's not doing what I want

Hi (I'm sorry in advance if I didn't understand your explanation properly, and if I'm telling you stuff you already know::), I think the friction needs to vary per-tyre depending on how much pressure the wheel is exerting on the road? I think the pressure each wheel exerts on the road will depend on the suspension compression? @ me if you reply, I may not notice otherwise:) (you can DM if I don't reply to your reply:)

#

If you can afford it (semi regular 50% off sales), https://assetstore.unity.com/packages/tools/physics/edy-s-vehicle-physics-403 is a superb "simple" vehicle physics implementation with full source code. If you're making a game (I guess as far as "simcade", like GTA-like driving; for proper simulation the same developer makes "vehicle physics pro" https://assetstore.unity.com/packages/tools/physics/vehicle-physics-pro-community-edition-153556 ; https://vehiclephysics.com/about/features/), I'd strongly recommend it. Even if you're trying to learn about how to do this yourself, Edy's already solved a bunch of awkward problems, working through the EVP source is how I've learned a load of stuff about vehicle physics (tl;dr: it's hard😅 ).

covert comet
#

Hello!! :) I'm wondering how I would set a particular collision up.

#

Here's a a player object facing a simple enemy. The enemy shoots a projectile at the player every few seconds. The things I need to happen are:
-The projectile should not collide physically with either the enemy or the player, but be affected by the projectile collider and the enemy/player collider overlapping.
-The projectile should be able to have their velocity and trajectory manipulated (rotated, mainly).

#

I was trying to use Rigidbody components for this but it's soooo clumsy. All I want to do is rotate the projectiles to move towards the player gradually (not simple a LookAt() call.) And I want trigger events to happen when the projectile hits the player.

#

What should I do here?

timid dove
# covert comet I was trying to use Rigidbody components for this but it's soooo clumsy. All I ...

You definitely want/need a Rigidbody here.
You will also want a trigger collider on the projectile, and use OnTriggerEnter to handle the collision in code.

As for the movement, you could make the rigidbody kinematic, which will let you completely control it in code. You can then use rb.MoveRotation to control its rotation, and rb.MovePosition to control its position. You should do these things in FixedUpdate

covert comet
#

That's what I'm doing. I'll update and see if there's a particular problem with this.

covert comet
#

The code for instantiating the enemy's projectile.

#

The enemy's projectile's fixedupdate.

#

The enemy should be shooting at me from ITS origin, but instead, all these projectiles are spawning at the origin. Very strange.

viral ginkgo
#

If you scale a parent gameobject, and then rotate its children you get these kinds of issues

#

If that's the case, just make sure the parent scale is 1,1,1

leaden sigil
#

Its the folding.

leaden sigil
viral ginkgo
#

Ah, yes

#

@leaden sigil I think you have weight paint on this

#

I'd just use seperate quads

#

With no vertex sharing between segments

Does it behave differently in your mesh editing tool?
I think it would look the same there as well

timid dove
#

MovePosition requires an absolute world space position to move to

#

you're giving it a direction vector

timid dove
covert comet
#

Aha

#

Thank youuu

viral ginkgo
#

@leaden sigil Hmm, I dunno

#

What's wrong with seperate quads anyway

#

I think thats gotta be very common in games with 2d ropes

#

You should just model a simple quad

#

And instantiate a chain of it with a nice for loop

#

Have different lengths of rope as well

leaden sigil
viral ginkgo
#

@leaden sigil I was suggesting generating joints in the for loop

#

so you can have variable length ropes

leaden sigil
viral ginkgo
#

Well then that's probably going to be a nice practice

#

unless you are in a hurry

leaden sigil
#

Nah lol.

polar leaf
#

I'm making a space dogfighting game (like Elite Dangerous and Star Citizen). As any of these games, ships and projectiles are super fast. This works extremely bad for collision detection. I've already made the projectiles bigger, changed Collision detection modes but it's still janky as hell (hits have a very hard time registering). Any tips for this?

#

I'm using trigger colliders. In my test I'm testing against a small stationary target

quasi shuttle
#

hello, i have an enemy with 20 colliders in bone objects. It causes huge physics times when there is about 15 enemies on quest 2 build. What would be the best approach to fix performance from colliders? 1 big collider works bad on vr :/

wraith junco
#

That + the frictional sideways damper seems to cancel out the sideways sliding pretty well

#

One thing I noticed is that the physx wheel colliders seem to suffer from the same sideways sliding on a slope (unless I'm just not setting them up correct).

twin nebula
#

So I've got a config joint and I'm setting the target position to a transform and the drives for X Y and Z are 6000 power 50 damp. I've tried others but it literally does nothing. Also most of the time it'll droop below the target

empty cipher
steel mortar
#

so for some reason the gameobject just glides up

#

when adding a character controller

#

without the controller it doesnt

timid dove
#

Pick one

wraith junco
tribal bobcat
#

Why my character controller component don't show gizmos for the capsule that's creating ? i'm using 2021.3.2f1 version

bleak umbra
tribal bobcat
#

Nope

#

Not working

#

Is it a bug?

bleak umbra
tribal bobcat
#

U sure?

#

First image using capsule collider

#

2nd using character controller

#

Yet no gizmos

bleak umbra
tribal bobcat
#

Oh

#

It was not

#

My bad

bleak umbra
tribal bobcat
#

Thanks

ripe sky
#

it's a video of my problem

#

it's not a virus or anything, it's just an flv file I recorded in obs

timid dove
#

put it on youtube or streamable or something

#

or directly embed in a format discord supports like mp4

mild swan
#

hi, i have trouble adding collision so that my character arm does not pass through the walls the way i made it make it hard so if you think you can help me... Please pm me or create a thread so that i can explain further and add image as well as screen-share. i would be grateful if you could help 👍

ripe sky
viral ginkgo
#

@ripe sky I am thinking your cars initial position might be outside the area where collisions work

#

check this out in physics settings

#

here

#

your initial coordinates were outside the 250 extents from origin

#

second coordinates were inside

#

You should probably think about having the mesh colliders in chunks.
And have a system to shift the world origin
So your coordinates don't ever get extreme

#

If you want to make a game with big maps

#

If you just want a quick fix, just increase the world extents

#

I'd also increase the world subdivisions
You can set extents 1000 and subdivisions 10 for example

ripe sky
# viral ginkgo

Thanks for the tip! However, this didn't really change anything in my case. I did even try to move the tunnel to a place where I already had a working (but smaller) one. My car fell down on the exact same spot, when I drove inside the tunnel

uncut sable
#

I have a little flag attached to the top of my tank, the flag has joints that go up it so that it will bend around as the player moves. However, my movements dont seem to be affecting the physics joints. How do I achieve this?

wraith junco
#

so you might need to add a collider and rigidbody to your flag

#

then you probably need to reference both rigidbodies in the joint

uncut sable
#

ill give it a try!

#

it bends perfectly fine when the head of the tank rotates on the X and Z axis but when it spins on the Y axis which is the only axis that it's supposed to in my game, there is no effect lol

wraith junco
#

I mean you could manually apply force to it, based on the angular velocity of your tank

#

you might be doing something wrong with the joint though, I don't really use these things

#

How are you rotating the tank?

#

To rotate any physics body without breaking it from the physics engine, you should be using addtorque

#

I think its called that

#

you definitely shouldn't be applying manual rotations if you want it to maintain it's physics capabilities

uncut sable
#

rip haha i definitely am applying manual rotations

viral ginkgo
#

At x = 320 like in your video

charred pelican
#

I'm trying to make a system where a player picks up an object and can hold it.
Currently, it

  1. Sends a raycast,
  2. turns off gravity and activates kinematic on the object hit by the raycast,
  3. Parents and moves hit object to "holding" point
    This system works, but because the object is kinematic it phases through solid objects.
    When it hits other rigidbodies, mass does not seem to take effect either, meaning if I make the picked up object (with a mass of 1) contact a rigid body (with a mass of 1000), it will act like there is no mass at all and hit it away.
    I've tried making it so that the object is not kinematic when it is being picked up, which results in it bouncing off surfaces when they contact anything. Fixes the phasing through solids issue though. If anyone can help that would be great.
#

Here is footage of that. You can see the pickup working perfectly, but it phases through solid objects. When a light object is picked up (mass of 1) and is hit against an object of mass 1000, mass does not seem to take any effect.

#

Here's when I set it to not kinematic.

mild swan
#

hi, i have trouble adding collision so that my character arm does not pass through the walls the way i made it make it hard so if you think you can help me... Please pm me or create a thread so that i can explain further and add image as well as screen-share. i would be grateful if you could help 👍
: useful info :
-the character can only turn and can't move.
-when i put rigidbody and collider the arm/racket just disassemble when touching the walls as shown in the image down here.

haughty smelt
#

ok, i just added tires and car physics layer
i dont want them to collide
i want everything else to collide with them
the road (on default layer) isnt colliding with the wheels (they are on on tires layer)

stiff topaz
#

I guess this is technically in physics? I have a 2d Tilemap collider but they have rounded corners

#

How do I not have this

#

I want the sharp edges, the rounded edges are nowhere else

#

not in sprite editor or anything

timid dove
stiff topaz
stiff topaz
#

I did automatic grid by cell size, then did custom shape, hit generate, and removed the rounding, and it's still tha tway

#

...and did not recreate the tilemap collider.

#

now it's working thank you

stuck bay
#

hello I am using unity cloth physics to animate a cape. I put colliders on the character dynamically on runtime through a physics prefab. they are set to the ragdoll layer which only interacts with itself. when I collide with other objects my character starts to spin wildly. I can't find an answer at this time.

winged herald
#

So I've found that OnTriggerExit2D doesn't seem to be guaranteed to be called. No, my layers are not set up incorrectly, and I have even enabled the "Send Callbacks on Disable" option in the Physics2D settings.
But when Trigger Colliders are disabled, sometimes, OnTriggerExit2D just does not get called.

Is this a bug or intention? I've found a not so perfomant workaround, but ideally, I'd like to just use the OnTriggerExit2D.

sullen panther
#

Is there a way to stop objects of high mass passing through objects of lower mass.

For example if you have a cube of low mass (1) and then "squash" it between 2 cubes of larger mass (10), the 2 high mass cubes just pass intersect instead of colliding. (if the mass of the 2 cubes was 1 (same as low mass cube) then it collides as expected).

Note, I am moving the objects by settings their RB.velocity component, not by moving their transforms

tardy compass
#

Is there a way to nullify a rb2d's contacts.relative velocity?
i tried to make a character controller by setting the rb.velocity.x, and once it hits the wall, it is told to have 0 velocity both from my script, and in the main rigidbody component, but when you jump, it launches the direction of the wall.
i found that what's happening when i jump is that this relative velocity goes from a wall contact to the normal rigidbody velocity, is there a way to stop this?
Picture: Rigidbody velocity 0, wantedvelocity, which is what im setting the rb.x to, and the weird "Relative velocity" with x=10

shell gulch
#

Im new to this area in game design so I got a question. i have a character that im working on and his robes im thinking of adding cloth physics, and im asking to the people that have experience whats the procedure for it and would it be better if i rig the loose robes and animate them seperately (away from unity ) or have unity to do the simulation and hope it turns out good?

timid dove
shell gulch
#

aight thank you

fluid lagoon
#

hi, is it possible to make a projectile collide with an object without losing momentum ?

#

i want the projectile to keep going; like a bullet that goes throw a carton box, it should not effect its momentum yet I want the carton to have some sort of impact debri

polar leaf
#

If I increase the time scale, will the physics be the same? (use case: I want to create some training scenarios for my AI and want to increase scale so the training is faster)

viral ginkgo
#

If you insist on having a collider on the projectile, you could keep track of the velocity from last fixedupdate and restore it in OnCollisionEnter

carmine basin
#

I'm trying to align a rigidbody's up with the normal of the ground below it using torques, as well as turning it around the y-axis to face the camera. Does anyone have any idea how I'd do this?

timid dove
#

Also if you want to do AI training, you should just use Physics.Simulate, rather than waiting for real time to elapse

fluid lagoon
#

@carmine basin @viral ginkgo thank you!

viral ginkgo
fluid lagoon
#

I'll actually use raycast for projecils like this , like u said, it aint the best for what I'm looking for.

viral ginkgo
# carmine basin I'm trying to align a rigidbody's up with the normal of the ground below it usin...
void ControlRotation(Rigidbody controlled, Transform target, float p = 1, float d = 1)
    {
        var deltaRot = target.transform.rotation * Quaternion.Inverse(controlled.rotation);
        deltaRot.ToAngleAxis(out float angle, out Vector3 axis);
        var moveToTargetTorque = (angle * axis) * p;
        var dampeningTorque = controlled.angularVelocity * -d;
        controlled.AddTorque(moveToTargetTorque + dampeningTorque, ForceMode.VelocityChange);
    }
#

from my super secret stash

carmine basin
#

lmao, i'm currently using a series of addForceAtPosition things

#

it works well, kinda, but I need to tweak to get rid of the wobble

viral ginkgo
#

thats poor mans addtorque

#

i was once like that

carmine basin
#

It works better for what I want than AddTorque does

viral ginkgo
#

then i obtained this piece of code

#

the transform that goes in the parameter here

#

its for getting a target rotation

#

this is pretty much a rotation set but torque makes it happen in the background

#

I should've put a Quaternion target in paramater instead of Transform target

#

Well you can do that

#

Would make more sense that way

carmine basin
#

I have managed to get it working quite well using my method

#

and using force at position cuts out the extra faff

#

easier to read and easier on my autism brain

#

praetor judging me heavily rn

timid dove
#

yes

viral ginkgo
#

I have spoken

timid dove
#

Add force at position is going to leave you with a net linear velocity

#

unless you perfectly cancel that out elsewhere

#

you also have to do a bunch of torque math to figure out how much torque you'll actually add

#

easier to just add the torque directly

carmine basin
#

I have cut all the extra math out. I'm making a hovering vehicle.

#

the extent of my math is literally just

        foreach (var item in hoverRayOrigins)
        {
            RaycastHit hitinfo;
            Physics.Raycast(item.position, -item.up, out hitinfo, raycastDistance, layerMask);
            rigid.AddForceAtPosition(hoverNormal * ( 1 - (hitinfo.distance / desiredHeight)) * hoverForce, item.
        }
#

Its like buoyancy but on land

#

i promise i know what im doing

jovial wraith
# carmine basin i promise i know what im doing

Its unclear to me whether you're satisfied with the answer that you got, so I'm going to weigh in. Sorry if it is redundant.

Trying to use AddForce/AddTorque to arrive at a specific target position is simulating the real-world engineering problem that the field of Controls deals with. There is no simple equation of "just add this force/torque and it will work perfectly." You're going to have to set up some kind of control system. BARGOS's code with the dampeningTorque is an example of what this would look like, but how well it works depends on the values of p and d. You have to tune the system to find the correct values of p and d to get the result you want. Higher p values will get it to arrive at the target faster, but also cause it to potentially overshoot and wobble. Higher d values will make it take longer to arrive at the target, but makes wobbles fade faster and potentially prevents them completely.

It's a simplified versions of a PID controller: https://en.wikipedia.org/wiki/PID_controller. Technically it is a PD controller, which is a PID controller with I = 0.

In your math, (1 - (distance / desiredHeight)) * hoverForce is equivalent to the p term (which stands for proportional, as it it is proportional to the distance from your target value). To avoid a wobble you need an additional term that dampens the motion -- a d term (which stands for derivative). It should work in the opposite direction of the p term, and it should be proportional to either the angular velocity of the rigidbody (simpler but less accurate) or the linear velocity of the point you're adding your force at minus the linear velocity of the center of mass (a bit more complex).

The manual tuning section of the PID controller article may be particularly helpful for getting a handle on the concept: https://en.wikipedia.org/wiki/PID_controller#Manual_tuning

carmine basin
#

I did attempt to use a PID controller. However, I seemed to struggle quite a bit with that. I think I was satisfied with the help that was given, even though it wasn't put into practice. I do appreciate your help though, too.

stone crag
#

im new to everything unity and are trying to put a box collider and rigid body on an asset but unity does not allow me to use both at the same time how can i fix this? using 2020.3

timid dove
#

THere's nothing wrong with putting a box collider and Rigidbody at the same time, unless you're trying to mix 2D and 3D

stone crag
timid dove
#

RIgidbody can go with BoxCollider
Rigidbody2D can go with BoxCollider2D

#

but you can't mix and match

polar leaf
#

Hi I'm making a spaceship 3d game (very high speeds) and I am running into all sorts of problems with colliders on projectiles, namely, projectiles hitting other projectiles, projectiles hitting the shooter and projectiles not detecting collisions. What is the best practice here? Seems with normal colliders I can't avoid them hitting the shooter, trigger colliders seem to have worst collision detection and I have read somewhere that you should avoid using colliders at all and have scripts doing raycasts to detect collisions.

tropic forge
#

hello, i made player controller using rigidbody, blocking x and z rotation, if i go to a corner, i can noclip....

polar leaf
stuck bay
#

How could I make a stick that acts like a ragdoll

timid dove
#

it's the same thing

stuck bay
#

did , sadly didnt find anything for my peanut brain

stuck bay
#

( idk if its better )

inner thistle
#

Compare the Y coordinate of a segment to the next one. If it's different, move towards it.

wise eagle
stuck bay
wise eagle
#

fixed isn't a good adjective, I would like to say if is like a animation

#

normally, to do a animation is a better way.

stuck bay
wise eagle
#

ah ok, I understand

#

in this case, you need a script that control all plataforms

stuck bay
#

they arent platforms , i want a lighsaber that acts that way

#

and I thought its better if its segments

wise eagle
#

is it a lightsaber like a nunchucks?

timid dove
#

You could also do this:
give each of the "tail" objects a PositionConstraint component: https://docs.unity3d.com/Manual/class-PositionConstraint.html

Have each constraint follow the object ahead of it in the chain (after baking in the offset with the Activate button), and set the weight of the constraint to like .8

stuck bay
#

I would like it to look like the chains of a nunchaku

wise eagle
#

Maybe, you can use joints too.

stuck bay
fluid lagoon
#

hey,

what to do when a projectile with sphere collider goes through an object without triggering OnCollisionEnter(Collision collision) ?

stuck bay
stuck bay
#

3 options

#

if u dont have bouncy bullets I suggest the 3 option

#

( use is trigger )

#

if u need the thing u are shooting to be pushed ,, naturally " by the bullet , use the 2 option

timid dove
stuck bay
#

When I move the "parent cube" , the "move cube" moves half the distance travelled by the "parent cube" and it doesnt move back into place

fluid lagoon
stuck bay
fluid lagoon
stuck bay
fluid lagoon
stuck bay
#

slow down maybe

#

but whats happening is the collision is skipped because the bullet move so fast trough frames , it just passes trough the object

#

I think

fluid lagoon
#

the bullet velocity is just 50 😄

stuck bay
#

weird

fluid lagoon
#

let me try to slow it down ... maybe something else is causing it

stuck bay
fluid lagoon
fluid lagoon
#

yup it worked right after 😄 , thanks a lot ^^

stuck bay
#

The part that I dont understand is weight

#

and sources

timid dove
#

I may have been overzealous with the constraint compontns, they might not be able to solve your issue 😛

timid dove
#

True love is unconditional

stuck bay
#

😉

stuck bay
#

so my love condition has been semi-filled

normal cargo
#

i tried to make sloped terrain, with a squeezed sphere and mesh collider, but somehow it seems to suck in the enemies that accidentally touch the small hill. why is this happening? it would make sense that the upward hill would push away objects, and not suck them in?

cedar trench
#

Not really a problem but Does anyone know how to make a titanfall-like movement system in unity

timid dove
#

that's a really complicated system

#

with lots of parts

#

break it down and focus on one at a time

tropic burrow
#

anybody here code their own physics? (like kinda) I still use the unity colliders but I made my own acceleration based system. I'm still working on some stuff like particles moving through walls. I was considering using a raycast to stop them before it happens but I dont know if thats good for the algorithm cause its like 20 particles a scene. Anywho would love ideas/comments https://twitter.com/chimp_northern/status/1554620958324965376

couple of levels randomized #madewithunity #unity3d #gaming #indie #indiedev #mobile #mobiledev #physics #programming #pixelart

▶ Play video
wise bobcat
#

i made a soft body a while back like in this video https://www.youtube.com/watch?v=F82BlnW5z6g and i finished it adn it was perfect but all of a sudden when testing stuff it started making it so when colliding with objects the spings got a new distance instead of springing back like springs

#

anyone know why springs would get a new distance?

#

(spring joints)

wind meadow
#

what is a way in unity to move two rigidbody objects simulataneously?

#

basically i have a parent with a rigid body2D component

#

and its child which also has a rigidbody2D component

#

what is a good way to move both of them at the same time once i apply a force?

timid dove
#

they will both be destroyed at the end of the current frame

wind meadow
#

how does that move them?

#

either that or you're trolling me and telling me subtley to not even attempt that

timid dove
#

move them?

#

Did I misread

#

I thought you said destroy..

#

did you edit it 🤔

#

If you want them to move together you either destroy the child's rigidbody or make the child's rigidbody kinematic

#

OR attach them with a physics joint

wind meadow
#

ah ok

#

no i didn't say destroy pre nor post edit

#

but i guess glad you weren't trolling

timid dove
#

ah sorry idk guess i'm going crazy lol

#

my bad

wind meadow
#

it's kewl

#

it works

#

TYSM

left plank
#

I have an object I'd like to be triggered by entering in contact with a trigger collider, but not the other physics-based colliders

#

if I send it to another layer, both get disabled, which isn't the effect I want to pursue

#

is there a way to work around this or should I refactor my script for it to target a child object that would carry the trigger itself?

timid dove
left plank
#

the problem being that the physics interact badly with another object, but that same object does need to get the trigger

#

so I guess that making a child to hold the trigger collider at the same position and tweaking the script to work with that would be a reasonable thing, but i wondered if it was possible to fine tune it for it to ignore one collider but not the other

timid dove
left plank
slow vine
#

(Collisions are a part of physics, right?🤔 🤣 ) I am having some problems with sphere colliders...

#

What are the relationships between the sphere collider's actual "world" size, the value of its radius on inspector panel and it's gameObject's localScale?

#

So I have about 200 objects, each having its own parent object(and different scale), I need to add one sphere collider with a precise radius of 10 on every single one of them...

normal cargo
#

any tips on how should i make my enemy objects to climb / jump over small obstacles that are in front of them?

#

should i make trigger box in front of them, and that would cause them to increas velocity upwards?

#

or am i doing something totally wrong here? i am using sphere collider for the round enemies, and box collider for the cubical enemies

#

on the image, only 2 of the green balls got over the obstacle, because the other ones were pushing them from behind

timid dove
#

the simple way to approach this is simply not to scale the parent

#

if you have some renderer or other component on the parent that needs to be scaled, move that renderer to a sibling object instead, and scale the sibling. Leave the parent at 1, 1, 1

fluid lagoon
#

hey i have a reglure 3d plan and a physical projectile with spherical collider

i have a script on the projectile to spawn an explosion once it hit any thing., but I keep receiving this error when it hits the plane Triggers on concave MeshColliders are not supported

jovial wraith
fluid lagoon
#

Thanks !

uneven spindle
#

Hello guys, can you help me solve my problem please?
I want to make my boat turn along the Y axis and only this axis but as you can see on this screen my boat is rotating along the three axis.
I used an AddTorque to make the rotation (I just used a constant value for this example to show that the issue doesn't come from my calculation).
So I don't understand why a force is applied on the other axis.

timid dove
#

combine that with gimbal lock, and euler angles in general being euler angles, and you get what you get

woeful cave
#

Gimbal lock sucks but quaternions... suck.

unique cave
woeful cave
#

Neat if you're a fan of CBT

fluid lagoon
#

hey, I'm debugging a trigger that is not working and I doubt that it has something to do with the collision matrIx

its similar to this image right here.

how do to enable the collision between ( Detector and water ) layers?, there aren't enough check boxes

left plank
#

my educated guess

fluid lagoon
fluid lagoon
#

hey, is the collider faster than the trigger ?

stuck bay
#

hey is this true ?

#

F(x) = n/x

if x -> 0-
y -> x * 10^0-
if x -> 0+
y -> x*10^0+

timid dove
stuck bay
#

yess sir

timid dove
#

not enough info really

#

what's n

#

n being positive or negative matters

stuck bay
#

n is a constant

timid dove
#

the sign of f(x) depends on the sign of n and of x

stuck bay
#

nahh f(x) = n/x is the same as y= n/x

steady bison
#

Need a lil help with bike physics. I am using a bike model, and did the following:

separated wheel collider from the mesh
attached configurable joints to the mesh ones
attached rigidbody on main bike parent
ignored adding anything on chain, chassis, brakes

Is that about right for a bike, or do I need to add/change something else?

#

Anyway main reason I'm asking is that despite separating the two, the wheel seems to fall down anyway

#

I locked the motions to stop it for now

delicate echo
#

heyy im just a newbie trying to make a game so far i built something following tutorials but im having trouble with collision2denter. if anyone has experience with this please do help I need it smiling_face_with_tear

#

im making the chrome dinosaur game where it requires the dinosaur to jump from the ground and I have set rigidbody and boxcollider to the dino and boxcollider to the ground but when I put the code the dinosaur flies haha rather than jumping

#

so I set a bool variable to check if its in the air as per the tutorial but for some reason my dino jumps once and doesn't do anything else

slim olive
#

how are we supposed to know where the problem is

#

are you doing a ground check?

#

do the collisions register?

atomic solar
#

Hello, sorry, I'm not sure which chat this is supposed to go in, but I'm having an issue that the physics in my built version of my game is different to the the physics in edit mode, does anyone know why this is happening, and how I can fix it?

#

Play mode, not edit mode

#

the one in the editor

inner thistle
#

You're using physics methods wrong ¯_(ツ)_/¯

atomic solar
#

I have no idea what that means

#

is that to do with fixed updates and delta time?

inner thistle
#

You haven't shown your code so pretty much impossible to say

atomic solar
#

okay, ill be a sec

#

ive never used the new input manager or callback contexts before either, so im sure that doesn't help

#

i can show more if you need, but i think this is all that is relavent

inner thistle
#

And in what way is the physics different?

atomic solar
#

the jump is shorter in build mode

#

nevermind, it isn't, i am so sorry for wasting your time, i don't know why i thought it was

#

thank you for your help regardless

delicate echo
#

do u know how to check if collisions did occur?

slim olive
#

usually do a debug.log

unique cave
# woeful cave Neat if you're a fan of CBT

The way quat * vector and quat * quat works is really neat. No clue how quaternions really work under the hood but quaternions are funny to work with. You dont need to know the math behind or (what x, y, z and w means etc.) to make use of quaternions

fluid lagoon
#

hey does anyone know how to solve this Math/physics issue ?

A projectile with a rigidbody component attached.
Given:
1 - the starting velocity of a projectile. (initial velocity)
2 - it has been traveling for 0.52 Seconds.
3 - it's initial position.
4 - it's position at 0.52 Seconds.

*Required: * Find the projectile velocity at 0.52 Seconds.

timid dove
fluid lagoon
timid dove
#

Are you just asking what the effect from gravity will be?

timid dove
#

so it's simulated once every Time.fixedDeltaTime seconds

#

so 0.52 seconds isn't really the question it's more like "how many physics simulation steps have occurred?"

#

so something like:

Vector3 initialVelocity = rb.velocity;
float timeElapsed = 0.52f;
int numberOfFixedUpdates = Mathf.FloorToInt(timeElapsed / Time.fixedDeltaTime);
Vector3 changePerFixedUpdate = Physics.gravity * Time.fixedDeltaTime;
Vector3 totalChange = changePerFixedUpdate * numberOfFixedUpdates;
Vector3 final = initialVelocity + totalChange;```
fluid lagoon
#

Thanks I'll give it a try.
I was thinking something simpler like: Vfinal = Vnow + (Physics.gravity * Time.fixedDeltaTime)

but I think you are more accurate, mine doesnt make much sense leaking the number of fixed updates

narrow solstice
#

i added bounciness to my projectile but now it doesnt interract with things it has code for

teal marlin
#

Hello, trying to calculate AngularVelocity without the use of a Rigidbody by comparing previousRotation to currentRotation and adding it to the currentRotation as a quaternion when not tethered to the object, but if I face the opposite direction i.e 180degree camera movement, the deltaRotation isnt applied as intended, what can I do?

spark zealot
#

im trying to figure out how to put gravity in any direction. so if for example, an arrow was pointing in a certain direction, say its rotation was 30°, 50°, and 70°, how would i change gravity towards that direction?

tender gulch
slim olive
#

is there any reason Physics.OverlapBox would fail to return any colliders even when it's called at the same position as the collider i'm checking?

#

I'm experiencing some sort of bug

#

I'm not passing any layer mask btw

#

basically it returns a collider the first time the object is enabled
I disable the object
then check again for a collider but it doesn't return anything

uneven shore
#

is there an easy way to create collider for inside collision? e.g. I want an object to be enclosed inside a circle, so I was hoping to use a circle collider.
But it automatically being pushed out since the colliders are "filled".

modern merlin
#

dynamic friction adds a force opposite to velocity with magnitude of the parameter?

timid dove
#

"the parameter"?

modern merlin
#

the number you set

timid dove
#

dynamic friction is like:
a = area of contact patch
c = coefficient of dynamic friction
n = normal force
f = a * c * n

modern merlin
#

which one of these do you set in the material

#

c?

#

or f

#

i mean documentation says "feels like" i want to calculate it

#

also it says 0 to 1 while i can go 0 to inf in the inspector

stuck bay
#

my main collider is resizing at runtime, any way to stop that?

timid dove
#

The others are circumstances of the contact between the objects

stuck bay
#

I need help to animate my character

lapis fossil
#

meaning

#

?

lapis latch
#

Why is implementing a simple jump this hard?

#

should I just ditch Character Controller and return to Rigidbodies?

merry sleet
#

Hello! Sorry for what seems to be a stupid question, but I cannot really get my head over this. I've managed to do this easily countless other times but in Unity for some reasons I'm definitely struggling for something so simple.
I'm trying to build a small 2D simulation and code-wise, everything is working kinda fine. I'm against a very big issue, though, with collisions.
Plainly speaking, I can't get any kind of wall collision working.

  • I've checked collision layers/and collision matrix; they're all fine.
  • My main rigid body is set on dynamic.
  • The wall I've tried both with/without a rigid body (and was set to static) and it has a collision.
  • none of the collisions are set on trigger.

I've tried looking up online and doing exact same things but for some reasons it does not seem to work for me; once the main body "player" walks, it just moves through the wall object.

I've tried using OnCollisionEnter2D to debug if they were actually seeing each other and they do.

That's it basically, I have no idea why my player just walks through walls.
Sorry again for the very basic question but I can't really find any working solution.
thanks

PS: I'm moving my character position through code

lapis latch
#

this might be a stupid question as well but, do the walls and the player have colliders?

merry sleet
lapis latch
#

is the position of the wall fixed?

merry sleet
#

Yep

lapis latch
#

unfix it and try again, if the wall moves you will at least know that they are colliding properly

#

I would suggest you to use character controller as it handles this stuff by itself and rather easy to use but I since I am trying and failing to make my character jump with it, I am not sure if I can make such suggestion

merry sleet
#

Ok actually I think I've managed to make it work, the issue is I was using

SetPositionAndRotation()

to move my character as I was using some acceleration and steering. I'll try to see if I can manage to implement the same effect without using it.

Thanks man

lapis latch
#

I was gonna write "I am a newbie as well so this is the extend of what I can suggest"

merry sleet
#

actually you kinda gave me the idea that it could be that, so thanks 😂

#

I'll also check this CharacterController, perhaps it will be helpful

lapis latch
#

I am glad one problem is solved at least 🥲

#

It seems quite useful for some purposes but jumping might not be one of them 🙃

merry sleet
#

Luckily my ants do not need that lol

lapis latch
#

yeah

#

I tried to copy the code in my script as well

#

controller.isGrounded doesn't seem to be working consistently

#

even weirder part is that when the character manages to jump, the jump height isn't consistent either

#

which might be related to isGrounded's inconsistency

merry sleet
#

Mmh

lapis latch
#

"A CharacterController is not affected by forces and will only move when you call the Move funtion. It will then carry out the movement but be constrained by collisions." it says

#

maybe Character Controller just isn't fit for a platformer or anything that isn't some sort of a strategy game?

#

for games that is

merry sleet
#

To be honest I'm not entirely sure as I've never used it and I would not like to mislead, but from what it seems, it seems to be capable of being used in a platformer, though I'm not sure.

lapis latch
#

the TPS tutorial I looked up was using it so I assumed it would be the "right way" of doing things

#

anyways, since nobody is here, let me ask it on #💻┃code-beginner to see if anyone has a solution over there

hallow charm
#

Write your own, since it means you will have control over what the different things are doing.

lapis latch
#

Shortcuts complicate stuff huh?

#

thanks for the input

jovial wraith
# lapis latch `controller.isGrounded` doesn't seem to be working consistently

You should make sure you always pull the CC downward via gravity when standing on the ground. If it moves directly parallel to the ground, it may not collide with the ground, which could cause the inconsistency.

You could also try using the collision flags instead of isGrounded. I'm not sure whether they'd be more reliable, but it's a thing to try.

Finally, you can always implement your own ground check with a raycast or extra collider or OverlapSphere.

lapis latch
#

thanks

#

I ditched Character Controller and working with Rigidbody, which works fine for most purposes but I am not sure how I can prevent the character from sliding now

#

Finally, you can always implement your own ground check with a raycast or extra collider or OverlapSphere.
I should've looked into raycast maybe

rose jolt
#

i am having issues with gravity not applying on the chain and the hinge not moving,

lapis latch
rose jolt
#

it went crazy now

lapis latch
# rose jolt thanks but

this video explains it very well but in short, isKinematic prevents any force on the object that isn't specifically specified by the object's script so you need to add the gravity with script
https://www.youtube.com/watch?v=e94KggaEAr4&ab_channel=iHeartGameDev

Learn the fundamentals of moving Characters in Unity3d with an introduction to character controllers!

This beginner-friendly tutorial is a thorough break down covering how we can move characters in Unity3d and explains the various options Unity has to offer: the built-in component, rigidbodies and custom character controllers!

UNITY SALE:
🛍️ ...

▶ Play video
#

you should probably watch the video instead of reading my half-assed explanation

jovial wraith
# rose jolt thanks but

isKinematic will make it ignore the joint completely. They just won't work together.

Chains are pretty hard to make. Make sure your colliders are not overlapping. That's probably why it is immediately exploding

rose jolt
jovial wraith
lapis latch
lapis latch
#

or should I just go for the hard math?

#

which I can do, I just don't want to bother

#

gotta go walk the dog now but I would appreciate any advice

jovial wraith
# lapis latch any easy solution for this?

Character controllers in general are a whole can of worms... Hard to give much advice without getting all the details of what you're doing now.

Upping friction might since sliding. Making it all kinematic and moving it exactly how you want it to move is probably best, though. Dynamic rbs are really for physics based games. Think Angry Birds or Moving Out or Human Fall Flat. Precision platformers really need a kinematic solution

rose jolt
#

i have seen a video of a chain of 3d balls with 2d images connected to them but i don't think it will look good close up in VR

rose jolt
#

it works i just need ti figure out code to stop it from over extending because that's when it freaks out

lapis latch
#

for this prototype I am making a generic TPS

modern merlin
#

so if i add rigidbody component with gravity to an object, it will fall flat according to its center of mass. but if i change object's scale it will fall on its side. how do i make an object with changed scale fall flat?

lapis latch
#

Well, ignore what I am saying since I am only thinking about the actual physics and not about programming. There might be a solution that works with all kinds of shapes for all I know

#

If you don't want the object to rotate at all you can freeze rotation on the specific axis for example

tawny dragon
#

Hey guys, I'm making a 2D top-down tanks game, and after making a pretty cool custom movement controller for the tank, my next step is handling collisions but I am at a complete loss at how todo it so that my movement stays accurate as I made it. I know the way to go with heavily precise custom movement controllers is a Kinematic Rigidbody2D, but that doesn't cover collisions with other static or kinematic physics objects. Using a dynamic Rigidbody2D makes my movement have momentum even after I set the friction to 100k, which isn't at all my wish, what do you guys recommend I do? Personally I have no idea on how to make a custom controller that accurately supports collisions and such

tawny dragon
timid dove
tawny dragon
timid dove
#

There are many ways you could get the desired effect.

normal cargo
magic needle
#

@safe plover (Replying here because its more physics related)
Here is the tutorial I used to learn active ragdoll part of the character : https://youtu.be/-pX-PobRLzk

Well in this video, we created an active ragdoll character like the ones Gang Beast / Humans Fall Flat / Totally accurate battle simulator. If you guys had any problems during this video, please let me know either in Discord channel or comments section. Let me know what I should create for the next video :)

This video helped me creating my cha...

▶ Play video
rose jolt
#

is there a way i can make the kinematic last chain link snap to the claw hand after the physics are applied or something of that nature? if i used a position constraint on the last chain link it disconnects from the rest of the chain

soft glade
#

Hello, started to work with wheels.
Trying to emulate Top Gear Rally's suspension and car behavior, but wheel colliders weren't behaving as desired and don't know how to tweak the settings to fix it (it drifted hard enough to turn the car 180 degrees, bounced too slow, suddenly bounced while turning and made the car fly away, etc)

Decided to make my own wheel collider using two cubes and one sphere with a wheel model:
-cubes connected, one above the other, by spring joint and configurable joint keeping movement in one axis.
-Sphere connected to bottom cube with hinge joint.

The suspension is connected to the car through a fixed joint on the top cube.
Suspension is acting closer to desired, but got an issue when trying to test movement:

#

Anyone who could happen to know how to go about fixing that?

soft glade
#

Clarification: used input to make the wheels apply torque and move the car forward. This for some reason makes the suspension object start bouncing back and forth, until it escalates and cascades into that.

timid dove
#

could just be a classic unstable fixed timestep spring simulation

#

or it could be a bug in your code

#

hard to say which

soft glade
#

There's no scripts on the suspension, only a playerController script applying torque to the spheres.
I suppose timestep might be the issue in that case, but how do I fix that? Never touched timestep settings.

warm slate
#

Ok this is weird. Not sure where to put it. We have debugged a mesh for render calls. But after all was said and done we found out a Configurable Joint is adding 16 draw calls even as an empty game object. URP project in VR. But I think either way Physics should not add draw calls right? Am I missing something?

warm slate
#

Is in the camera view at runtime. Would there be a way to test that? I have gizmos off. I am going to be testing on an empty project

timid dove
warm slate
cedar charm
#

bruh??? I just copy pasted my unity project for versioning purposes and suddenly new copy of unity project is having wild torque difference...?

#

the part where I apply torque is way more intense

#

yet all variables are same

#

wtf notlikethis

timid dove
cedar charm
#

dont think so... plus hardware is exactly same

#

i used fixedupdate in few places indeed

#

i literally placed 2 unity projects on my screens now

#

one of them has some crazy torque rate with same variable

#

other one has normal torques

timid dove
#

Show your code

cedar charm
#

nvm about fixedupdate, its a single run function

rb.angularVelocity = new Vector3(0, 0, turnForce);
#

one unity project has normal, other one has x50 torque at this moment

timid dove
#

well you're not using torques at all

#

where does turnForce come from

cedar charm
#

yeah, just angular velocity

timid dove
#

and where does this code run

#

etc

cedar charm
#

its fixed public variable i set from inspector (both same)

timid dove
#

share the whole script ideally

cedar charm
#

i tried goggling "vsync" check on both instances of unity

#

same stuff

#

😩

#

toggling*

timid dove
#

Did you mess with time scale?

#

check

cedar charm
#

i did not. where can i see it?

timid dove
#

project settings -> Time

cedar charm
#

not me.. but maybe some files went wild, checking

timid dove
#

also your code could change it

cedar charm
#

same exact in both windows

#

hmm nope.. only time i messed with "time" at all was simple time.detlatime stuff

timid dove
#

show your whole script?

cedar charm
#

eh its a mess, hastebin?

timid dove
#

yes

#

also are you using version control? (you should)

#

if so you could easily detect any differences between the two

#

Doing a print($"Turn force is {turnForce}"); is not a bad idea either

cedar charm
#

anyways uh

#

both in scene

#

and in play

#

my "turn force" is manually 200

#

not 50

#

in inspector

cedar charm
#

this was specific case, and im just confused why it even happened.. starting to sound like weird unity bug unless you find something dumb in that .cs

#

Can I use github desktop to see diff?

timid dove
#

probably

cedar charm
#

i heard of those diff tools specifically tho

#

checking

timid dove
#

but just looking at your status

#

should tell you if anything changed

cedar charm
#

which one you'd recommend

#

for git diff

timid dove
#

you don't need a diff tool

#

just look at your changed files

cedar charm
#

i want to compare 2 supposedly

#

identical

#

follders

timid dove
#

You can compare each of them to the git index

#

by just looking at any unstaged changes

cedar charm
#

ah ye

#

I mean like

timid dove
#

as long as both are on the same commit

cedar charm
#

2 different folders

#

outside git fdolder (one of them)

#

one of them is outside

timid dove
#

you could have cloned it with git

#

instead of copy and pasting

cedar charm
#

yeh i guess

#

dam man its just really confusing what just happened 😄 maybe its some bug indeed

#

i could try tweaking values again to make them normal

#

i guess that'd be more sane by now hahah

#

i heard of project "physics" settings like gravity, maybe theres something like uh, global angular drag

#

but even if there is

#

i never touched it so wtf 😩

timid dove
#

drag wouldn't be relevant here

cedar charm
#

ye its not here

polar leaf
#

@cedar charm are the read only properties of the rigid body different in the editor? (Like the inertia tensor stuff)

cedar charm
#

i think it was, but only to do with the fact that I raised the physics applied object to see if it could be colliders freaking out

#

i solved it all by having to manually adjust the variables of applied torques etc

#

but crazy what just happened lmao, must be some sadistic bug in unity or my brain

#

in one of those situations i just freak out about "Wtf is even going on" not "ok how do i fix this then"

#

which isnt good i guess

#

and by "i think it was", i mean this field only

nova tangle
#

Was working on GPU instancing and procedural island generation and now my physics dont work... or atleast no gravity is applied to this cube or anything, which i only setup for this purpose.

My physics works in other scenes, just not this procedural one.

I feel like i've tried everything:

- Gravity in settings is set
- Cube not colliding with anything
- Moved the cube faaar away from anything
- No constraints
- Rigidbody is not asleep
- Restarted Unity

Dont know what else to do

timid dove
#

Physics.autoSimulate?

tired cape
#

Hello friends, I have a question regarding 2d point effectors/2d gravity… hopefully someone can help , any information is appreciated…

#

Basically, I have a script that I made that I then found out does the same thing (basically) as a 2d point effector. This is like, a top down space ship and there are planets with gravity that of course have an effect on your flying, however, when I exit the range of influence of the planet my ship continues to fly off as if there is a constant force being applied to it, seemingly in the direction that the ship exited the planets range of influence. In my project settings I have 2d physics gravity on x and y axis set to 0, idk if that has any effect on what I’m doing or not but I figure I should add that. Even if I fly in the opposite direction of the mystery force (like you’d have to to slow down in 0 gravity), as soon as I let go of my move forward key, the mystery force is still applied.

#

I’m new to Unity and coding so this is likely a simple fix… but I’m not quite sure what it could be

tired cape
#

Ignore the channel name lol

graceful star
#

Hey yall, I have spent upwards of ten hours trying to get the following to work with very little success.

I'm developing a virtual reality nursing simulation on the Oculus Quest 2. The patient in my simulation is a baby, and one of the capabilities of this baby must be that it is able to sit up (from laying down) when the player pushes the back of the baby. To accomplish this, I made use of a hinge joint, which did exactly what I wanted.

Later, I was required to add a RigidBody to the root GameObject in the baby's GameObject hierarchy, which began the onslaught of bugs I have since been dealing with. The following is a screenshot of the GameObject hierarchy for the baby:

#

The RigidBody is on the root (titled "Baby"), and the hinge joint is on the pelvis (which contains the torso, head, arms, etc.). Initially, both legs were also children of the pelvis, but in order to have the pelvis/upper body rotate independently from the legs, I had to move the legs to be siblings with the pelvis instead. Unfortunately, in doing so, the baby's legs now flop around whenever someone makes contact with them. And not only do they flop around, but they get flung reasonably far away somewhat randomly after pushed around a little bit, and just behave in a generally strange manner.

What is my solution here? I need the RigidBody on the root "Baby" GameObject, I need the Hinge Joint on the pelvis, and I need the legs to be outside of the pelvis in order to facilitate appropriate bending at the hinge.

Any suggestions are highly appreciated!

open parrot
#

hey! I have a question on using Rigidbody component.
I have a player and a cube, both has rigidbody and collider component. whenever i move the player near cube, player slide and stick to cube. when i try to move back the player starts vibrating, then if apply more force then the player starts moving back. I dont want my player to stick to the cube.

can anyone help me with this?

nova tangle
timid dove
timid dove
nova tangle
# timid dove How did you confirm the Cube is not colliding with anything?

I found the issue... It is a very odd one, but i got it. I am working with networking. but for testing i just setup a single player scene (absolutely no networking in the scene). But for some reason it does not run physics-calculations without the network manager in the scene... Very odd. But thank you anyway for trying! It's very nice of you.

timid dove
#

Which is why I asked

nova tangle
molten tangle
#

Hello I made a elevator using animation, the problem is when I get on the elevator it goes up but my player controller remains at the place where it was standing. Even though my elevator has collider why it just go through me how can I solve this?

high spear
molten tangle
#

what if I tell you there are 8 elevators !!

inner thistle
#

When the player steps on an elevator, you make the player a child of that specific elevator. When they step off you unparent them.

high spear
molten tangle
#

private void OnTriggerStay(Collider other)
{
Debug.Log(other.name);
if(other.name == "XR Origin")
{
other.transform.SetParent(gameObject.transform.parent);
}
}

high spear
#

I assume one of those two gameobjects have a RigidBody?

molten tangle
#

This script is on Lift GameObject not on LiftManager GameObject, but still it makes my XR Origin child of Lift Manager

#

Okay the error was in the code it's

#

other.transform.SetParent(gameObject.transform);

high spear
molten tangle
high spear
timid dove
molten tangle
molten tangle
steep bison
#

is there a way to change the grid snapping size for box colliders?

warm pilot
#

I have a chain of ArticulationBody elements. If I ArticulationBodyHead.SetJointPositions how do I force an update to get the transform of the tail? Right now the tail's transform is unchanging.

#
    private void SetRandomReachableTarget() {
        SetRandomPose();
        SetTargetToPose();
    }

    private void SetRandomPose() {
        for (int i = 0; i < targets.Count; ++i) {
            targets[i] = Random.Range(-1f, 1f) * 180.0f;
        }
        Debug.Log("targets=" + string.Join(",", targets));
        bodyHead.SetJointPositions(targets);  // must be in degrees

        for (int i = 0; i < targets.Count; ++i) {
            targets[i] *= Mathf.Deg2Rad;
        }
        bodyHead.SetDriveTargets(targets); // must be in radians
    }

    private void SetTargetToPose() {
        Transform eet = bodyTail.transform;
        target.transform.SetPositionAndRotation(eet.position,eet.rotation);
        Debug.Log("p="+eet.position + "\tr="+eet.rotation);
    }```
torpid marten
#

Quick question, do mesh colliders use ressources on their own, or only if theres some rigidbody who would be effected by it? Would make a huge scene with hundreds of colliders be any less performant than a scene with one mesh, if theres only one rigidbody in both?

keen lynx
#

Does anyone know offhand if an AABB is always aligned to its original coordinate axes, or if it inherits from its parent object? For example, if I rotate the parent object, will that invalidate the AABB?

bleak umbra
keen lynx
#

Axis Aligned Bounding Box. My question is: which axes?

#

The documentation just says "aligned with coordinate axes"

bleak umbra
#

those are world axes

#

there are no other axes, the local ones are virtual

keen lynx
#

That makes sense! Thanks for the clarification.

timid dove
#

It's very easy to tell if a point is inside an AABB

#

For a rotated box, not so much, the math gets much more complicated

keen lynx
eager berry
#

Hey, so I have this rigidbody boat that is floating on water, I'm having trouble when my player is trying to stand on this boat. I can't seem to get the boat not to be affected by the players velocity and so the boat just sinks whenever I stand on it. Anyone know a way to get my player to not affect the rigidbody's velocity?

viral ginkgo
#

@eager berry Make the boat heavier

#

And also scale the forces on the boat with its mass

timid dove
#

The player will have a platform and the boat should be unaffected by the player

eager berry
timid dove
#

the boat too

desert wharf
#

hey i need help. Whenever i have my scene window next to my game window and start my game. the player which is based on a rb flies up when i am facing a specific direction. but when i pull the game window out of the unity editor everything works fine

#

why?

timid dove
desert wharf
#

i dont think it has anything to do with code, but maybe i can show some footage

#

can i pm u ?

#

nvm i think it has to do with it

timid dove
desert wharf
#

wait, so its like this. there is a specific direction and if i walk towards it, after like 0.5 seconds i start floating

desert wharf
#

right*

#

ill share the code

#

if you dont understand certain things i can try to explain it to you

timid dove
desert wharf
#

one second

#

like this?

timid dove
#

yes

desert wharf
#

do you know why this happens?

timid dove
#

not yet lol

#

My brain's also kinda fried from the workday so I kinda opened your script and my mind went blank

#

This seems a little sketchy though:
rb.velocity = new Vector3(limitedVel.x, rb.velocity.z, limitedVel.z);

desert wharf
#

haha can relate, im just very courious what the reason could be XD

timid dove
#

Should the middle one be y?

desert wharf
#

omfg

#

THXXX

#

Ill try out

#

its working

#

thank you very much

#

can i ask u something?

raw lark
#

I need to calculate how long it would take to zero-out an angular velocity. I've got a simple spaceship model where different ships have different characteristics of how much torque force they can apply each second, up to a certain maximum rotation speed for the ship. I've got AI turning to face a certain position but at some point before it reaches that direction it needs to start counter-steering so the ship ends up facing the target, hopefully all as snappy as possible. I think I have a very basic handle on inertia tensor, mass, angular dampening, but I can't quite visualize how to put it all together.
Any help, guides, examples, comments or terms I should be searching for?

timid dove
spark zealot
#

ive been trying to limit my movement speed in any gravity. currently, i just have limiting the speed by getting the magnitude of the velocity with the y value removed, and if the magnitude is greater than a max speed variable it sets it to the max speed. that works completely fine for up and down gravity's, but for gravity's like left and right, forward and back, and any other direction, it doesnt work at all. ive been doing research for a few hours and i cant figure it out.

urban geyser
#

I'm trying to make a 3D snowmobile, I'm using wheel colliders but as soon as I go a little bit too fast it has 0 grip and drift a lot, how can I increase grip?

#

The "wheels" at the rear make the sled move

tropic nexus
#

This seems like such a simple issue I cannot get it to work.
I have a 3D game where the player is able to carry objects.
HOW do I make him carry objects such as his movement speed/force affects the object he is carrying?

I tried fix joints but then the player can fling himself upwards with the object.
I tried spring joints but even with very high spring force the object lags behind and wobbles.
I tried moving the carried object with rb.MovePosition but that is buggy when encountering static walls as it always tries positioning itself inside it so it just vibrates in place.

Can someone point me in the right direction?

timid dove
timid dove
tropic nexus
timid dove
#

but is the player's movement ffected by the object at all?

tropic nexus
#

I need to prevent the smaller player character from being able to push around obstacles that would normally be too heavy for him with just holding an object

tropic nexus
timid dove
#

so can't you just make the object kinematic and set it as a child of the player?

#

And just do a mass check before picking it up

tropic nexus
#

If you use things like rb.MovePosition or transform.translate you can fling dynamic objects like baseballs with just turning around while holding an object

#

I also dont want any visual syncing issues. So the held object should stay in place and not lag behind when turing around for example

timid dove
#

I tried moving the carried object with rb.MovePosition but that is buggy when encountering static walls as it always tries possitioning itself inside it so it just vibrates in place.
This should not be the case

#

I think you were probably doing something a bit off there

#

can you show the code you had for that?

tropic nexus
#

How is that not the case when you try to move a dynamic object into a static collider every frame? What should happen according to you? It makes sense it happens.

#

It was either that or movement without interpolation which looked even worse

timid dove
#

the problem is if you are doing that every frame and you are doing it with transform.Translate for example, yes you will get penetration

#

it works properly if you move via the Rigidbody in FixedUpdate

tropic nexus
#

Does not matter anyway as it does not do what I want

#

As it will ignore the characters mass when being moved and not slow him down when pushing another object

flint anchor
#

how do i make my character unaffected by the environment? sometimes if i hit a wall weird my player will spin. character has a rigidbody and capsule collider, and room has a mesh collider

bleak umbra
flint anchor
#

i used a rigidbody cuz i want him to push stuff that he touches or interact with other things

bleak umbra
flint anchor
#

can a kinematic controller roll and go upside down

bleak umbra
#

it can do whatever you program it to do.

flint anchor
#

okay i must have been thinking of something else then

verbal jolt
#

I'm doing the Counting Prototype tutorial and I'm basically trying to get a box to move back and forth to collect balls. However, the balls keep passing through the walls of my box. I applied a rigid body to the balls and set collision to continuous, but no luck. any advice?

timid dove
verbal jolt
#

what do you mean?

timid dove
#

As opposed to teleporting them via their Transforms

verbal jolt
#

they're spawning in the air and falling into the box. When I move the box, they pass through the walls instead of staying inside the box

timid dove
verbal jolt
#

I think I understand what you mean and changed the movement of the box to AddForce. The balls are staying better, but not entirely. If I move one direction at top speed and change direction, they go through. Also, when I get to 3~4 balls, they start falling through the bottom

#

nvm, changing the mass of the balls seems to have fixed it. Thank you for your help @timid dove 👍🏼

tranquil thorn
#

hello

#

this is exactly the issue im having

#

it's getting stuck on the collider like that

#

and if i unfreeze rotation, it goes all over the place

#

thing is, I want to keep my player a flat rectangle

#

is there anyway to workout around it? I don't know how to do the thing with linear force described in the link

bitter void
#

How do I get the angle between 2 points?

bleak umbra
#

if you mean directions, you can use Vector3.Angle(a, b)

bitter void
#

Vector3.Angle doesn't seem to be giving me the correct result

bleak umbra
#

You need to be more precise about what you want

bitter void
#

I have a thin long cube, and 2 vectors. I need to rotate it such that it looks like this

bleak umbra
#

cube.transform.forward = b - a

#

cube.transform.position = (a + b) / 2

bitter void
bleak umbra
#

this assumes the cube‘s long axis is z

bitter void
#

got what I wanted, thanks @bleak umbra

limpid quartz
#

Hey people. Been working on a project for about 3 years, yadda yadda etc!

#

Does continuous collision detection actually work? I have an extremely simple setup where a rocket or bullet gets fired out and should always collide with the wall

#

And half of the time they just seem to completely clip through

#

Is it completely broken, or am I doing something wrong? I'm not moving these via script, they simply receive AddForce(force, ForceMode.Impulse) when created. Their transforms aren't changed manually or anything like that

#

They're obviously quite small and fast-moving projectiles

timid dove
unique cave
#

both doesnt even need to move as seen here (both are dynamic tho). discrete physics engines are quite bad at resolving large forces from many sides of the object at the same time

merry sleet
#

Hello! I'm getting some issues with my raycast reflections in 2D and I hope someone has any idea why this could happen.
Basically I'm using a raycast to detect some collisions for my simulation, though there is an issue with my normals and reflections whenever I try to use them in order to "find" the new direction of my entities.
As you can see (hopefully, drawing aint the best lol), the yellow arrow is my initial direction;
now, most of the times I get the supposed result of a reflection, which is the green arrow. (I calculate that using Vector2.Reflect(incomingRay, hit.normal).
Sometimes, though, especially in situations like this one, the reflection happens to be similar to the red arrow which I completely cannot understand me being stoopid.
Here's my code and thanks if anyone knows what it could be.

        RaycastHit2D hit = Physics2D.Raycast(position, new Vector3(velocity.x, velocity.y, 0f), 1.0f, 8); //8=3=walls

        if (hit.collider != null)
        {
            Debug.DrawLine(position, hit.point, Color.yellow, 10.0f);
            Vector2 fromTo = hit.point - position;
            Vector2 reflection = Vector2.Reflect(fromTo, hit.normal);
            Debug.DrawLine(hit.point, reflection, Color.red, 10.0f);
        }
timid dove
#

Wait also your DrawLine is not correct

#

the second one

merry sleet
#

I'll try though there are no other objects in the area that could impact the hitray.

timid dove
#

That should be a DrawRay since you're using a position and a direction instead of two positions

#

reflection is a direction vector

merry sleet
#

I shall try now, thanks.

#

Ok so it seems to kinda be working but still have some issues similar to that one. I'm starting to think it might be because there are too many updates and as my entity is still turning, the ray finds another direction to move on, and doing that every frame somehow seems to fuck it up a bit.
I'll try soon to reduce the frequency of the updates and write here if I still find issues.
Thank you!

desert wharf
#

hey everyone, i need help. I want to create a shooting mechanic in 2d. I have a weapon and a Guntip to fire from. the guntip gameobject is a child of the gun, so the position doesnt change. I dont know how to get around that.

timid dove
#

as long as the gun moves

#

the tip will move too

#

don't be confused by the position numbers in the inspector not changing. That's the local position

desert wharf
#

hey thanks for your answer

timid dove
#

but you should really do this btw:

GameObject tmpBullet = Instantiate(bullet, gunTip.position, gunTip.rotation);```
#

and you don't need the second line

desert wharf
#

wdym

timid dove
#

you can spawn an object at a particular position, you don't need to set the position in a separate line

desert wharf
#

ah yes

#

i fixed it already but i have another question

desert wharf
#

after instantiating it

timid dove
#

rotate it in what way

#

where do you want it to point?

desert wharf
#

wait let me explain

#

ill send some pics

#

basically this is the layout, a square with a gun, and at the tip of the gun the Bullet will spawn

timid dove
#

ok and?

#

What about the rotation?

desert wharf
#

but i need to rotate the bullet another 90 degrees, so it points to the mouse

timid dove
#

where's the mouse?

#

Why 90 degrees?

timid dove
desert wharf
#

wait a sec

timid dove
#

all you need to do is set the gun tip to be rotated the way you want the spawned bullet to be rotated in the editor

desert wharf
#

rn the bullets go in the wrong direction

desert wharf
#

thanks it works

#

have a nice evening ^^

summer sentinel
#

i dont think this is physics related but this is the most fitting channel for my problem.
i have a capsule collider for a player and whenever i start the bottom part clips a tiny bit into the ground when it falls, meaning that after it falls enough of the collider is inside the ground which causes the player to get stuck and clip.
for the floor i am using several planes.

#

nevermind, i found the problem

frank shadow
paper lodge
#

I deleted my message after testing stuff out and figuring they share the same physics scene a bit better.

I dont understand why moments ago it wasnt finding it though hmm, anyway pardon the distruption

civic field
#

Your solution will depend on how you implemented the one way platform

plucky thunder
#

should i first add gravity or drag?

frosty ore
#

@sturdy prairie finally Did it! lol,, all physics, hinges, and springs for the launch... nothing but a collider on the bolt, and a piece of script to orientate it towards its velocity direction, 3 day to get it from Kids toy image, -> blender model -> physics setup, to repeatable launch

#

got a 900 feet range, and that's just with the current settings, can't angle it much more but the spring could easily get some punch

snow surge
#

I feel like I'm going crazy, does it the order rigidbodies are instantiated matter when parenting to other rigidbodies?

Working on a multiplayer physics airship game, and need players to stick to the ship as it moves around, but for some reason I'm getting a very strange difference in behavior when player 2 joins and player 1 is already on a ship.

Option 1 works perfectly when the player spawns in after the ship spawns, but makes players that existed before the ship slide off in the direction of the velocity.
Option 2 works perfectly when the player spawns in before the ship spawns in, but players that spawn in afterward stay perfectly still when the ship is in motion.

// Character code

if (onGround && !isJumpOnCooldown)
{
    // Option 1
    Rigidbody platformRb = platform.attachedRigidbody;
    if (platformRb != null)
        rb.velocity = platformRb.GetPointVelocity(rb.position);
   
   // Option 2
   rb.velocity = Vector3.zero; 
}
snow surge
#

Turns out setting the ship's rigidbody to kinematic and back removes and then re-adds the ship to the end of the list, fixing the issue, but there's gotta be a better way, right?

wraith junco
#

Does anyone have any knowledge on multi-raycast suspension? Do you essentially just model the lower-half of the wheel with angled raycasts and then start at the fully compressed position, and just move that modeled wheel down until it hits something?

#

This topic is so dry online, hard to find anything

snow surge
#

I'd suggest having a wheel collider that represents the highest position the wheel can be, so that the raycasts don't ever start below a surface, it also stops any suspension code from hitting extremely compressed values, which can wind up sending vehicles to space.

#

Do you need pointers on the actual suspension physics?

wraith junco
#

Yes, that's how I did it with a single raycast. Shoots directly down starting at the fully compressed position and compression is determined based on the hit position

#

I mean

#

I just want to know how it's done

snow surge
#

That's how I've always seen it done in some variation. The wheel's collider usually doesn't actually move in and of itself, but the wheel is just a visual aspect

wraith junco
#

If I model the half wheel, and move that down, that's gonna be a pretty big performance hit

#

yeah that's tricky with multi-raycast suspension

#

since the "spring length" will be different based on different angles of the wheel

#

if I didn't move the raycasts up and down

snow surge
#

Are you talking about just something like this?

wraith junco
#

that actually

#

might be a better idea

snow surge
#

Yeah that's what I did in my project awhile ago, I just took the value farthest from the target as the suspension level

wraith junco
#

This is how I'm currently doing it

#

which doesn't make much sense

snow surge
#

ah I see yeah lol, since the suspension goes downwards I raycast downwards too

#

You can also do a sweeptest I believe

#

on the wheel collider

wraith junco
#

yep, sweeptest is how physx does it I believe

#

The photo above drives fine up rocky terrain and such, since I just get the raycast that first hit something, determine the compression, and add the force upwards. The tricky part is just determining the location of the visual wheel. Someone yesterday told me to negate the direction of the ray with the radius. Using the Y value from that seemed to work fine at non excessive angles, it just didn't feel like the right calculation for whatever reason

#

but yeah raycasting downward or sweeptesting seems like a much better idea

snow surge
#

Yeah the radial casts are a bit strange since suspension typically doesn't go forward and back lol, sometimes we miss the forest for the trees

wraith junco
#

yep, that's completely the problem

#

How exactly do you calculate the suspension length in your photo above?

#

Obviously it gets shorter towards the sides

#

Its 4am, this might be a really obvious question that I'm not seeing

snow surge
#

You just take the delta like so
float distOffsetFromBottom = maxRayLength - hit.distance;

wraith junco
#

Wonderful, thanks

snow surge
#

gotchu 👍

robust belfry
#

I am studying physics department and I am new university student now. I wanna develop physics simulation apps but I dont know how to start for learning physics.

#

do you advice me for learning physics tutorials with unity?

stuck bay
timid dove
#

with a loop presumably

stuck bay
#

oh yeah

#

I never thought of that

#

thx

wraith junco
#

@snow surge How exactly do you resolve collisions with your wheel collider method? The selected spot is the first collision among all of the raycasts. I take that raycast collision point and subtract the scaled radius from it and apply that to the wheel's y position.

#

however, the bottom of the wheel penetrates the ground

#

This is how I setup the raycasts. Red is the radius scaled along the wheel and the blue is max suspension length

#

I think this might be a flawed way of doing it.

#

I'll be testing sweeps next

undone ruin
#

hi i need some help

#

i attacked a poligon collider to this right shin

#

and when i see it it also apply the collider to the boot child

#

also the boot has it's own collider separately

#

how can i make the rightshin collider to be only on the blue capsule

#

nvm i finnished by separating the child and make a different script

snow surge
snow surge
#

The forumula for ray length is sin(acos(normalizedRayXPosition)) * wheelRadius

wraith junco
#

Regardless, I think I've got something working better with sweeptests

charred lava
#

So just out of curiosity... when working with Rigidbodies and Rigidbody.AddForceAtPosition, is the force additive? So if I have like 4 thrusters on the bottom of a ship and apply 10N to each one, will the applied force overall actually equate to 40N? Just trying to figure this out so I can accurately apply forces.

timid dove
#

that thruster scenario is pretty much exactly what that function was made for

charred lava
#

Awesome, ty!

lone axle
timid dove
uneven shore
#

hey guys, I have a TilemapCollider2D and when I'm calling ClosestPoint I keep getting the same point - even though it's not inside the collider and the collider isn't disabled.

Any idea why, and on how to actually get the closest point?

timid dove
uneven shore
#

@timid dove I actually found the issue; apparently when there is both a CompositeCollider and a TilemapCollider2D, it's important to call that method on the CompositeCollider and not the TilemapCollider2D. Thanks though!

distant iron
#

How would you make a trajectory function?

#

I did get something to work but it doesn't handle rotation of the go at all (it's a plank like go) and it looks not that good

robust belfry
#

I want to make vehicle that have soft body tires. I created soft body tire and I want to add force like a wheel is rotating. I added addForce to child's Rigidbody but these tires cannot rotate and cannot move like a wheel. How to fix this problem?

lost widget
#

I'm trying to make a controller for a submarine, and I'd like the pitch and yaw of the vessel to be controlled by a torque, so that the rotation can still be affected by other interactions. I'm having trouble figuring out just how I would interpret a desired rotation into a torque that would rotate towards that rotation. I've been looking at other solutions for similar problems, and I've found the documentation for the RigidBody.MoveRotation() method, but I'm not sure that this will do what I want it to.

An example of why I think I want to use torque rater than MoveRotation would be if the vessel were to be trapped under a heavy rock. I don't want the vessel to just arbitrarily be able to rotate around and push the rock off of itself. If the torque that the vessel is able to exert isn't enough to move the rock, then I don't want it to be able to.

If anyone knows how I could approach this please let me know.

#

also, specifics would be greatly appreciated, as right now I'm still somewhat confused on just how I'm going to get the desired rotation, just that I'll be using mouse input to rotate around x and y axis respectively.

timid dove
lost widget
#

Yes, I think so, but I don't know how to calculate how much torque I should add. I know somehow it needs to depend on a desired position but I don't know of whatever equation I might use to find that.

timid dove
#

you have inputs from the player

#

and they can correspond directly with torques being added around particular axes
Or at least to setting the rudder of the ship to a certain position which applies a particular torque.

#

You would only worry about a "desired heading" or "desired orientation" if you were making some kind of autopilot

dense coyote
#

So I have a simple game structure like this: