#How do I remove the turning lock and
1 messages · Page 1 of 1 (latest)
Unless you are moving the legs separately you only need a rigidbody on the root object of the cow and apply movement there. You should also use force functions to make changes to physics objects. Use AddForce to move it and AddTorque to apply rotation. You may also need to set the center of gravity to be much lower as if there is a large weight high up it will naturally want to topple over. Removing friction might help there too.
what means removing friction here?
I have no physic materials
Any colliders will have a physics material and if an object has a rigidbody then it will use the physics material to decide how to react when touching them. All will have a default material. You can just create a new one and assign it to the bottom parts of the cow
I have found a fix for turning, but the cow shakes when I'm turning
Cube_rb3.MoveRotation(Cube_rb3.rotation * deltaRotation_left);
Cube_rb4.MoveRotation(Cube_rb4.rotation * deltaRotation_left);
Yeah, MoveRotation is fine too
That's how it looks now
I can rotate the cow without any limits now
also
I use only a, w, d here
no s
for controlling
The wobble could be because you look to have a rigidbody on all cubes. If you have only one on the root object of the cow then all the other colliders will be combined into one and you will have a rigid cow. Currently you can see the legs wobbling, probably because they are separate. Or do you need them separate?
what do you mean legs separate?
Do the leg cubes have rigidbodies?
Normally for a character there should only be one rigidbody and you apply the motion there. When you have child rigidbodies things get more complicated. If you really need that you will probably need to use joints to connect them. I would recommend having a single root object that has one rigidbody and the legs are just colliders as children of it. All the colliders in that hierarchy will be bound together into one shape that is controlled by the root rigidbody
well, I want to apply force exactly to legs, because when I tried applying it to body things got bad
well, I mean Cube as a body
maybe with Cow it would be ok
That was the right approach. Just need to ensure theres only one rb
which approach?
but how would I apply force to legs if there will be one rigidbody?
that's possible to?
Why do you want to apply force to the legs? You would normally have a single object that you move around and the legs are handled by just animation. Unless essential for a game feature the legs should be cosmetic
I want it to move more logical, if I apply force to a whole body it would rotate over the center
tho I know that it still doesn't move fully logical
I just want to make sure the controls wouldn't be something of sort of drifting on ice
Sure. I would think of it more like a single cube that you are moving. You can have friction on that however you like to get the feel of it. Applying forces will be from its centre and so will move it forward etc. The legs are then just cosmetic and can even not have colliders. Just have a single cube at the root object with the rb. You are basically driving around a cube
Or, you can put 4 spheres at the base of the cube if you need to round out the movement
This is what could work. Just a single rb on the root object. The legs are then cosmetic
@coarse socket How can I move into a direction but not direction of some exact local or world position?
the way in my code it moves on a direction when I press w key is wrong
because it moves on an exact local or world position
meaning if I rotate cow it will move by it's back to the position
So are you doing AddForce(transform.forward * forwardSpeed) for forward motion?
yes
I have added a weight but that doesn't do any effect
the only thing what it can do is to make a different gravity of the whole object
You shouldn't directly modify the velocity but rather use forces or the MovePosition function
isn't moveposition for instantly moving?
No, it is for moving using physics. Teleporting is when you just set the position directly. Perhaps try rb.MovePosition(transform.foward*forwardSpeed);
The MovePosition will set a force/velocity that will get to the target point by the next update (or as far as it can depending on collisions)
I put Cube_rb.AddForce(-transform.right * speed);
The problem with that is that a continuous force will accelerate it. The MovePosition option will keep to a fixed speed - if that's what you want
what is a fixed speed?
Oh, the tranform right would strafe it right
for me on velocity it made it go forward
Like a car, a force is like holding the accelerator. Keeping it on will make you go faster and faster.
Try the MovePosition I suggested above with the transform.forward vector. Get forward working first
can you give me the line?
rb.MovePosition(transform.foward*forwardSpeed);
To be more precise: rb.MovePosition(transform.foward * forwardSpeed * Time.deltaTime);
Actually if you are in Update just use deltaTime
But this should really be done in FixedUpdate
why should I use time thing?
if (Input.GetKey(KeyCode.W))
{
Cube_rb.MovePosition(transform.forward * speed);
}
idk why but it spins and goes under the ground
on any speed
The MovePosition defines where you want it in the next FixedUpdate, so to be "correct" you need to make it a fraction of the fixedDeltaTime if you want the speed to be units per second. Not essential but correct. This will basically divide it by 50 for the 50 frames per second the physics system normally updates
Try a very low speed and check that the cows forward direction is in its Z axis. Make sure the Scene view is showing local and look at the axis when it is selected
Now I found the issue kinda fixed it and the other EVEN WEIRDER appeared
that one was due to moveposition
Cube_rb.MovePosition(transform.right * speed);
when I press w it tps me under the ground
and then when I continue press w I get stuck going up to the floor
Check the axis of the cow. The blue Z axis should be facing forward and the green Y should be up
how can I check it?
Select it in the scene view and check that the scene view top left settings are like the other image I posted
Set to Local
Ok so are the axes like my pic?