#⚛️┃physics
1 messages · Page 1 of 1 (latest)
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
ok
i think the problem lied with the tilemap2d collider
i changed it to a temporary Polygon collideer
and it is working
is there any real downside of changing springjoint's spring value to 0 instead of destroying it every time?
it continues to use resources I guess
Hi there, I have a car that stutters and I tried adding SmoothDamp and it still stutters but the game's environment looks smoother
I'm not really knowledgeable on unity yet but a guess i'd have is a weird collider interaction
That was it. I need to bring down spring suspension and spring dampness 🙂
lets gooooo
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?
I have this problem when my car goes too fast and hits the ground. Seems to be a mass issue.
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
how can i detect when 2 object collide with each other with a strong force
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?
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;
thank you!
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?
Real spring forces don't apply constant force, there's a proportional force to how far they are stretched away from the resting position
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
@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
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
np
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
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.
right so i dont need a navmeshagent i just need to query the navmesh surface
i'll give it a try
oh nice that worked better than i expected thanks!
if anyone wants to know what I did it's even simpler than I thought under collision detections i just had to set it to continuous
if you have rigibodies and colliders the force should be applied your question is kinda vague though so you might not be asking the right thing
I want to play a sound when the ragdoll hit the ground, but only if it hits with a strong force
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
this is me completely bs ing but maybe it'll help. Try set an if statement that tracks the speed of the character under a trigger method (not sure if method is the right word) if it hits a certain speed threshold in the ground collide then you play the audio. Hope this helps
I'm new so this might not help but to me it seems it's because you set detecting collisions off so it wouldn't detect anything including an OnTriggerExit
yeah hope it helps
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
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?
@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.
no i tried moving it really up and it tps down to exact height which is slightly above ground
as shown here
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.
i edited the base offset again and again till it is now on the ground
not sure if its the best practice
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
@quartz wyvern Hmm, try locking y rotation maybe?
oh that seemed to have fixed it
Also set the rb.velocity to zero in fixedupdate
thought i needed that unlocked due to using move rotation
nope
so the locked rotations only apply specifically to applied forces not move functions
Your issue probably accumulating rotational velocity
While you are using the rotation sets
yeh the jittery stopped if i stopped moving for a second or two
Maybe it was messing with interpolation
But I was suspecting linear velocity really
i'll zero them out every frame just to be sure
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
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?
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 ?
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 ?
interpolation doesn't do anything to the physics simulation
try playing with things like Sleep Threshold, Default Contact Offset, etc... in the physics settings
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:
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
You could use numerous rigidbodies and joints to make the rope but Id just simulate the rope myself with simple C# script assuming you dont necessarily want the rope to be able to interact with other colliders and physics bodies (so it would just swing freely without taking its envirnonment into account)
does an ArticulationBody contain JointDrive s?
it seems likely but it's not explicit in the documentation.
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
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
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)
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
give the children their own scripts and colliders (they don't need a Rigidbody, just one on the parent will do). Have the child script detect the collision and report it up to a "master" script on the parent by calling a function on the parent script
it's one extra script
but you tell me the opposite
¯_(ツ)_/¯
one? hm yeah maybe
Most mature projects have hundreds/thousands of scripts.
As long as the game is not trivial
hm unluckily I have never seen a large game made in unity from the editor perspective
anyway still I'd like to
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😅 ).
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?
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
That's what I'm doing. I'll update and see if there's a particular problem with this.
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.
I suspect the parent object named "Zipline rope" might be scaled
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
That's not the problem i am trying to showcase, thanks tho.
Its the folding.
The weird folding.
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
your FixedUpdate is responsible for this
MovePosition requires an absolute world space position to move to
you're giving it a direction vector
Nope.
you'll want something like:
void FixedUpdate() {
rb.MovePosition(rb.position + rb.rotation * Vector3.forward * Time.deltaTime);
}
@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
Or just use many hinge joints.
@leaden sigil I was suggesting generating joints in the for loop
so you can have variable length ropes
No idea how todo that lol.
Nah lol.
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
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 :/
Yeah I talked to a few smart guys and apparently the way to solve this (for arcade type cars, nothing fancy) is to have the suspension addforce in the global up direction, instead of relative to the wheel well
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).
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
most likely because it will depend on your frame rate. if projectile is able to move 2 frames you might miss it. If it is extremly fast you can do it hit scan instead using raycast. and then just animate your lasers without coliders.it will require some tricky math to do, but htat would solve the problem
so for some reason the gameobject just glides up
when adding a character controller
without the controller it doesnt
You shouldn't have both Rigidbody and CharacterController
Pick one
Physx collision detection is an awful way of doing bullet collision detection. Every physics tick, save the position from the last tick and the current tick of the projectile(s) you're working with. Shoot a line between them. If the line hits something, then you can determine that your bullet hit something
Why my character controller component don't show gizmos for the capsule that's creating ? i'm using 2021.3.2f1 version
select the object, make sure its not folded, make sure you are in scene view, make sure gizmos are turned on, make sure its actually in view and not too small/large
no, you are doing something wrong
U sure?
First image using capsule collider
2nd using character controller
Yet no gizmos
is it disabled in the gizmo menu?
Okay can someone help me with this
it's a video of my problem
it's not a virus or anything, it's just an flv file I recorded in obs
put it on youtube or streamable or something
or directly embed in a format discord supports like mp4
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 👍
didn't know discorded supported mp4😅
@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
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
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?
I could be wrong, but a joint might need two rigidbodies to work
so you might need to add a collider and rigidbody to your flag
then you probably need to reference both rigidbodies in the joint
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
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
rip haha i definitely am applying manual rotations
It would drop through the surface with default settings i mean
At x = 320 like in your video
I'm trying to make a system where a player picks up an object and can hold it.
Currently, it
- Sends a raycast,
- turns off gravity and activates kinematic on the object hit by the raycast,
- 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.
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.
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)
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
you can make a custom physics shape for the sprite in the sprite editor
but they aren't rounded in the sprite editor they're already square
show it
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
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.
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.
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
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
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?
I know this is about cloth physics but you probably will have a much better time with this question in #🔀┃art-asset-workflow
aight thank you
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
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)
I think what you might want here is just making the projectile raycast based
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
No. As BARGOS says, you would need to raycast in order to do this. Alternatively, put a collider marked as a trigger on the box if it does not need to collide with anything else or does not have a rigidbody
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?
physics will not change as long as your physics code was written properly 😛
Also if you want to do AI training, you should just use Physics.Simulate, rather than waiting for real time to elapse
@carmine basin @viral ginkgo thank you!
yeah but it will be hard to get a nice collision normal from this
and the projectile might skip thin objects if its made with trigger colliders
@fluid lagoon
I'll actually use raycast for projecils like this , like u said, it aint the best for what I'm looking for.
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
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
It works better for what I want than AddTorque does
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
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
yes
I have spoken
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
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
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
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.
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
what happens when you try?
THere's nothing wrong with putting a box collider and Rigidbody at the same time, unless you're trying to mix 2D and 3D
Yeha you';re trying to mix 2d and 3d
RIgidbody can go with BoxCollider
Rigidbody2D can go with BoxCollider2D
but you can't mix and match
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.
hello, i made player controller using rigidbody, blocking x and z rotation, if i go to a corner, i can noclip....
I just had a similar experience and in my case the problem was the tuning. Tuning them is not easy but my advice is to spend some time around with it. Start tuning each parameter individually and play around not just with amounts but also signs. Now mine is working well
How could I make a stick that acts like a ragdoll
look up a ragdoll tutorial
it's the same thing
did , sadly didnt find anything for my peanut brain
Compare the Y coordinate of a segment to the next one. If it's different, move towards it.
is the movement fixed?
wdym fixed?
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.
sure but if I move the base randomly , can't really animate that
they arent platforms , i want a lighsaber that acts that way
and I thought its better if its segments
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
I would like it to look like the chains of a nunchaku
I will look into it thx
Maybe, you can use joints too.
looked at them for a good while , never got how they worked
hey,
what to do when a projectile with sphere collider goes through an object without triggering OnCollisionEnter(Collision collision) ?
btw with this would the rotation work like this
make it slower, predict impact or use is trigger
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
it would not but if you wanted it to you can do that with RotationConstraints, or combine the two into one with ParentConstraints
gotcha , love ya and thx
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
i'm not familiar with "predict impact" option , but option 3 is not possible because I need it to collide with other things and I'm not surfe of making the bullet slower option either.. how slow are we talking ?
dk
depends on the bullet
and with what do u need the bullet to collide?
props , top table objects like books, bottles , plates, forks .. etc
and u want them to just be pushed by the bullet?
I'll try to slow it down and make collider a bit bigger than the bullet just to see if that would fix the problem
yes
it wont
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
the bullet velocity is just 50 😄
weird
let me try to slow it down ... maybe something else is causing it
maybe the layers arent colliding?
yeah :D, i've just checked,i had 2 layers with almost the same name, i unchecked the wrong one apparently.
I'll try it now
lmao
yup it worked right after 😄 , thanks a lot ^^
I dont understand them
The part that I dont understand is weight
and sources
I may have been overzealous with the constraint compontns, they might not be able to solve your issue 😛
bruh, my love is fading away
True love is unconditional
sadly this one has a "working solution" condition
😉
well thx to this I found the lookat/aim constrain, that will help with the rotation part of my problem
so my love condition has been semi-filled
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?
Not really a problem but Does anyone know how to make a titanfall-like movement system in unity
that's a really complicated system
with lots of parts
break it down and focus on one at a time
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
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)
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?
Just call Destroy on them both
they will both be destroyed at the end of the current frame
how does that move them?
either that or you're trolling me and telling me subtley to not even attempt that
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
ah ok
no i didn't say destroy pre nor post edit
but i guess glad you weren't trolling
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?
Use layer based collisions or just disambiguate by tag or component in the OnTriggerEnter method
it's in fact the case. i have a OnTriggerEnter() method with tag comparisons and identifying the right collider, but that one gets disabled too if the layer of collisions is disabled
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
I'm not totally sure I'm following you but everything can usually be solved with an additional collider on a child object on a different layer
i think we're saying the same thing. my bad i kinda suck at explaining things clearly
(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...
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
the world size of the collider is basically the radius * transform.lossyScale which is basically all of the scales of the object and all its parents multiplied together
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
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
presumably your plane has a mesh collider on it and the convex button is not checked. Checking convex should fix the issue and, assuming the plane is actually flat, will not cause any other problems
Thanks !
Got it. Thanks!
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.
AddTorque is in world space
combine that with gimbal lock, and euler angles in general being euler angles, and you get what you get
You could try https://docs.unity3d.com/ScriptReference/Rigidbody.AddRelativeTorque.html to add torque in the Rigidbody's local space
Gimbal lock sucks but quaternions... suck.
Gimbal does but quaternions doesnt, they are very neat
Neat if you're a fan of CBT
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
thanks !!
hey, is the collider faster than the trigger ?
is y supposed to be F(x)?
yess sir
n is a constant
the sign of f(x) depends on the sign of n and of x
nahh f(x) = n/x is the same as y= n/x
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
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
how are we supposed to know where the problem is
are you doing a ground check?
do the collisions register?
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
You're using physics methods wrong ¯_(ツ)_/¯
You haven't shown your code so pretty much impossible to say
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
And in what way is the physics different?
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
so the ground check is done through a boolean statement but i think the collisions do not register
do u know how to check if collisions did occur?
usually do a debug.log
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
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.
the velocity won't change ever unless:
- it hits something
- it has gravity
- it has drag
the velocity certainly changes due to gravity, you can even see it on the rigidbody component that it changes slightly over time.
ok that's what I'm asking you though
Are you just asking what the effect from gravity will be?
yes
Well unity uses a discrete physics simulation
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;```
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
i added bounciness to my projectile but now it doesnt interract with things it has code for
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?
for reference
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?
Get the direction vector. Set Physics gravity to that direction.
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
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".
EdgeCollider2D
dynamic friction adds a force opposite to velocity with magnitude of the parameter?
"the parameter"?
the number you set
dynamic friction is like:
a = area of contact patch
c = coefficient of dynamic friction
n = normal force
f = a * c * n
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
my main collider is resizing at runtime, any way to stop that?
C
The others are circumstances of the contact between the objects
I need help to animate my character
Why is implementing a simple jump this hard?
should I just ditch Character Controller and return to Rigidbodies?
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
this might be a stupid question as well but, do the walls and the player have colliders?
Yeah.
I was thinking that perhaps they do not work as I'm setting my position through code?
is the position of the wall fixed?
Yep
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
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
I was gonna write "I am a newbie as well so this is the extend of what I can suggest"
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
I am glad one problem is solved at least 🥲
It seems quite useful for some purposes but jumping might not be one of them 🙃
Luckily my ants do not need that lol
Have you tried checking this? It speaks about jumping
https://docs.unity3d.com/ScriptReference/CharacterController.Move.html
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
Mmh
"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
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.
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
My suggestion is always to avoid using the ready-made controller
Write your own, since it means you will have control over what the different things are doing.
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.
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
i am having issues with gravity not applying on the chain and the hinge not moving,
isKinematic prevents the gravity part
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:
🛍️ ...
you should probably watch the video instead of reading my half-assed explanation
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
thanks, is there a way to create a chain with 2 ends where 1 end is controlled by the player on the other is anchored?
Make the end links isKinematic and the middle ones dynamic
Don't ask me, I barely know how to use AddForce 😦
any easy solution for this?
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
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
i made a bigger chain loop and i don't think they are touching in scene mode and they are going less crazy its still not smooth do i need to limit the hinge or something?
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
it works i just need ti figure out code to stop it from over extending because that's when it freaks out
I am only trying to get accustomed with Unity in general since I don't know what I should do after completing the junior developer pathway I decided to make random prototypes
for this prototype I am making a generic TPS
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?
this is highly dependant on the object you are talking about
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
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
My script already handles momentum and even has a custom property to control how good the tank's breaks are
Using a dynamic Rigidbody2D makes my movement have momentum even after I set the friction to 100k, which isn't at all my wish
You can write code to do anything you want. You can set velocity directly whenever you want, add forces whenever you want, etc. Friction is not the only way to slow things down.
Hmm, so instead of using MoveRotation or MovePosition, overriding the velocity and angularVelocity I should get the desired effect?
There are many ways you could get the desired effect.
if you want to get rid of momentum, i think you can just code it. when you are not pressing any movement key, you can force the rigid bodys speed to 0 ?
@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...
awesome thank you
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
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?
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.
could just be a classic unstable fixed timestep spring simulation
or it could be a bug in your code
hard to say which
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.
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?
is it from a gizmo maybe>
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
gizmos off. Maybe scene view closed entirely?
Oh it is the gizmo. I see it now. I never realized it was drawing in camera view
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 
most likely you have framerate-dependent code
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
doesn't mean much. It's still possible to write framerate dependent code with FixedUpdate
Show your code
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
yeah, just angular velocity
its fixed public variable i set from inspector (both same)
share the whole script ideally
i tried goggling "vsync" check on both instances of unity
same stuff
😩
toggling*
i did not. where can i see it?
project settings -> Time
not me.. but maybe some files went wild, checking
also your code could change it
same exact in both windows
hmm nope.. only time i messed with "time" at all was simple time.detlatime stuff
show your whole script?
eh its a mess, hastebin?
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
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
anyways uh
both in scene
and in play
my "turn force" is manually 200
not 50
in inspector
yeh
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?
probably
You can compare each of them to the git index
by just looking at any unstaged changes
as long as both are on the same commit
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 😩
drag wouldn't be relevant here
@cedar charm are the read only properties of the rigid body different in the editor? (Like the inertia tensor stuff)
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
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
Time scale?
Physics.autoSimulate?
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
I did a quick screen recording in hopes of demonstrating what's happening. https://youtu.be/GNMn-j_C_fk
Ignore the channel name lol
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!
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?
Already checked time scale, and why would it be autoSimulate if it works in other scenes?
Bump on this :-)
How did you confirm the Cube is not colliding with anything?
Just checking off the possibilities
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.
Yeah because the networking library probably turns off auto simulation
Which is why I asked
Makes sense. Thanks man <3
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?
I suggest move your player as child of the elevator game object
What that exactly means, you want me to put my player controller as a child of elevator object, is that even a solution?
what if I tell you there are 8 elevators !!
When the player steps on an elevator, you make the player a child of that specific elevator. When they step off you unparent them.
yuppy, you can use transform.parent
It still doesn't work, controller stays where it is, even when I put my controller as a child of elevator in hierarchy
private void OnTriggerStay(Collider other)
{
Debug.Log(other.name);
if(other.name == "XR Origin")
{
other.transform.SetParent(gameObject.transform.parent);
}
}
I assume one of those two gameobjects have a RigidBody?
Okay now everything works fine, there is one issue only, when ever this code runs my XR Origin becomes child of Lift Manager I want it to become child of Lift GameObject
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);
I think its should be other.gameObject.transfrom or other.gameObject.name
It's working fine now but there is a problem as I reach 1st floor and start moving player controller fells down why is that
is the movement of the game object elevator going up is handle by the animator?
why are you setting the parent to the elevator's parent and not the elevator itself
Yes it is done through animator
I did that in the starting, I corrected that mistake now I make it child of elevator
is there a way to change the grid snapping size for box colliders?
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);
}```
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?
try it and let us know
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?
what do you think AABB stands for
Axis Aligned Bounding Box. My question is: which axes?
The documentation just says "aligned with coordinate axes"
That makes sense! Thanks for the clarification.
The whole point of AABBs is that they use the world axes to make bounds calculations extremely fast
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
I understand, I just didn't understand the nomenclature of "coordinate axes". I thought maybe they were checked against their parent transform. But I get the whole thing now, it was cleared up.
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?
@eager berry Make the boat heavier
And also scale the forces on the boat with its mass
the cheeky way is this:
Make a child object of the boat:
- give it a kinematic Rigidbody
- give it a non-trigger collider that rests at the top of the boat.
This child is the surface your player will stand on
The player will have a platform and the boat should be unaffected by the player
thank you so much! the only problem with this is that my player kind of sinks into the ground and stutters back upwards. Do you know any way of solving this?
make sure you're actually only moving your player in a physics-friendly way.
the boat too
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?
no idea you'd have to share code etc.
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
what makes you think it doens't have to do with code?
wait, so its like this. there is a specific direction and if i walk towards it, after like 0.5 seconds i start floating
i tried something but it wasnt rifht
right*
ill share the code
if you dont understand certain things i can try to explain it to you
please share via paste site as per #854851968446365696
yes
do you know why this happens?
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);
haha can relate, im just very courious what the reason could be XD
Should the middle one be y?
omfg
THXXX
Ill try out
its working
thank you very much
can i ask u something?
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?
If you just use ForceMode.Acceleration or VelocityChange the math is greatly simplified
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.
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
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?
The concept is correct but you have to just use vector projection to find the component of velocity orthogonal to the gravity direction
you want his movement speed to affect the object, or the other way around?
Basically if a BIG player is holding the object I would like the object to be moved with larger force.
I have 2 different sized characters and I need their weight/force to affect how they can manipulate this object
but is the player's movement ffected by the object at all?
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
No. Does not need to be at all
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
Not picking it up. Thats not the issue. But hitting other objects with the held object
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
MovePosition will do that yes. Translate will not
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?
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
the physics engine detects the collision and only moves the object as far as it should go without them overlapping
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
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
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
generally what people do to get their characters under control and prevent "weird" things is to not use a rigidbody (or rather physics system collisions and forces) for character movement
i used a rigidbody cuz i want him to push stuff that he touches or interact with other things
you can do that with a kinematic controller too
can a kinematic controller roll and go upside down
it can do whatever you program it to do.
okay i must have been thinking of something else then
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?
It's not enough to just slap a Rigidbody on them. You need to actually move them via the Rigidbody
what do you mean?
As opposed to teleporting them via their Transforms
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
ok but how are you moving them and/or the box? That' what I'm talking about
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 👍🏼
hello
How to reproduce: 1. Open the user's attached "Moving Blocks.zip" project 2. Open the "SampleScene" Scene 3. Enter Play Mode 4. Move...
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
How do I get the angle between 2 points?
There is no angle between points
if you mean directions, you can use Vector3.Angle(a, b)
I have 2 Vector3s, need the angle between them
Vector3.Angle doesn't seem to be giving me the correct result
You need to be more precise about what you want
@bleak umbra
I have a thin long cube, and 2 vectors. I need to rotate it such that it looks like this
I can lerp this, lerp works fine
this assumes the cube‘s long axis is z
got what I wanted, thanks @bleak umbra
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
Continuous collision works but it's not perfect, especially if both objects are moving and the smaller they are and faster they are the less reliable it is
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
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);
}
your raycast is probably hitting a different object than you expect. Print out the name of the object you hit?
Wait also your DrawLine is not correct
the second one
I'll try though there are no other objects in the area that could impact the hitray.
That should be a DrawRay since you're using a position and a direction instead of two positions
reflection is a direction vector
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!
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.
the guntip gameobject is a child of the gun, so the position doesnt change. I dont know how to get around that.
The position certainly does change
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
hey thanks for your answer
but you should really do this btw:
GameObject tmpBullet = Instantiate(bullet, gunTip.position, gunTip.rotation);```
and you don't need the second line
wdym
you can spawn an object at a particular position, you don't need to set the position in a separate line
how can i rotate the tmpBullet around the z axis?
after instantiating it
what's the goal?
rotate it in what way
where do you want it to point?
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
but i need to rotate the bullet another 90 degrees, so it points to the mouse
this code I gave you will already give the bullet the same rotation that the gun tip has
wait a sec
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
rn the bullets go in the wrong direction
ill try wait
thanks it works
have a nice evening ^^
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
Hey guys. I'm trying to make one way platform on a tilemap using platform effector 2D. It's working as intended besides when I'm running. As you can see the player gets stuck on the next tile. Does anyone know a fix for this?
https://gyazo.com/23a9856227801793eebbbe0c641b4505
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
The problem is getting stuck in the wall ?
Your solution will depend on how you implemented the one way platform
should i first add gravity or drag?
@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
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;
}
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?
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
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?
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
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
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
Are you talking about just something like this?
Yeah that's what I did in my project awhile ago, I just took the value farthest from the target as the suspension level
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
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
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
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
You just take the delta like so
float distOffsetFromBottom = maxRayLength - hit.distance;
Wonderful, thanks
gotchu 👍
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?
How do you cast so many rays?
with a loop presumably
@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
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
What formula are you using to get the ray's target length?
The forumula for ray length is sin(acos(normalizedRayXPosition)) * wheelRadius
oh, I was using pythagorean theorem to find the length
Regardless, I think I've got something working better with sweeptests
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.
yes it's additive
that thruster scenario is pretty much exactly what that function was made for
Awesome, ty!
am hello i am new in unity. Why does my character transfer collisions if I already add a 2D box collider?
What do you mean by "transfer collisions"?
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?
I'm going to lean in the direction of it's more likely there's something wrong with your setup than a bug with that function. Maybe share more details about your setup?
@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!
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
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?
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.
Seems clear you'd want to just use AddTorque, no? Or even AddForceAtPosition to add oblique forces at the rudders
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.
I don't think it's dependent on any desired anything
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
So I have a simple game structure like this:
