I have designed a cycles of rotational orientations to accomplish a run like movement for this spider character. It looks good, just using MoveRotation the rotations I designated accomplish the desired orientations, but MoveRotation alone shifts the limbs too quickly. when I try to feed the MoveRotation method a Mathf.Lerp or Mathf.LerpAngle algorithm everything gets all jumpy, shuddery and can sometimes rotate to unexpected positions. I want to use Rigidbody2D.MoveRotation so the character has realistic weight, does anyone have any ideas?
I think the only way to make it look realistic is with the animator. Is there a particular reason you want to use MoveRotation rather than rotating transforms? Could you share the code?
If there are colliders on the limbs, you might need to set it to animate physics and reduce the physics fixed time. If there’s a reason not to animate it, maybe you could animate a float field of the script and use that to determine rotation.
I hear you, but I’m confident if I can establish the right kind of shock absorption and the right pace of rotational movement I can get a totally fluid, adequately realistic outcome.
the first of a cycle of four rotational arrangements:
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) {
//the order will be : inner left, outer right, outer left, inner right (this is the cycle of which legs are contacting the ground when)
movingRight = true;
// lerp
if (runCycleDuration >= 0.6f) {
/*lerpingOne = true;
lerpingTwo = false;
lerpingThree = false;
lerpingFour = false;
lerpingFive = false;
lerpingSix = false;
lerpingSeven = false;
lerpingEight = false;*/
innerRightLegTopRigidbody.MoveRotation(/*lerpAngleInnerRightTopOne*/myRigidbody.rotation - 24);
innerRightLegBottomRigidbody.MoveRotation(/*lerpAngleInnerRightBottomOne*/myRigidbody.rotation - 174);
innerLeftLegTopRigidbody.MoveRotation(/*lerpAngleInnerLeftTopSeven*/myRigidbody.rotation - 104);
innerLeftLegBottomRigidbody.MoveRotation(/*lerpAngleInnerLeftBottomOne*/myRigidbody.rotation - 40);
outerRightLegTopRigidbody.MoveRotation(/*lerpAngleOuterRightTopOne*/myRigidbody.rotation - 58);
outerRightLegBottomRigidbody.MoveRotation(/*lerpAngleOuterRightBottomOne*/myRigidbody.rotation - 132);
outerLeftLegTopRigidbody.MoveRotation(/*lerpAngleOuterLeftTopOne*/myRigidbody.rotation - 158);
outerLeftLegBottomRigidbody.MoveRotation(/*lerpAngleOuterLeftBottomOne*/myRigidbody.rotation - 10);
}
this is my cyclical timer function:
void Timers() {
if (movingRight) {
runCycleDuration -= Time.deltaTime;
if (runCycleDuration < 0) {
runCycleDuration = 0.8f;
}
}
if (movingLeft) {
runCycleDurationTwo -= Time.deltaTime;
etc...
}
}
}
then this is how I tried to lerp but failed:
void LerpingOne() {
if (lerpingOne) {
lerpAngleInnerRightTopOne = Mathf.Lerp(innerRightLegTopRigidbody.rotation, myRigidbody.rotation - 24, Time.deltaTime * lerpSpeed);
lerpAngleInnerRightBottomOne = Mathf.Lerp(innerRightLegBottomRigidbody.rotation, myRigidbody.rotation - 174, Time.deltaTime * lerpSpeed);
lerpAngleInnerLeftTopOne = Mathf.Lerp(innerLeftLegTopRigidbody.rotation, myRigidbody.rotation - 104, Time.deltaTime * lerpSpeed);
lerpAngleInnerLeftBottomOne = Mathf.Lerp(innerLeftLegBottomRigidbody.rotation, myRigidbody.rotation - 40, Time.deltaTime * lerpSpeed);
lerpAngleOuterRightTopOne = Mathf.Lerp(outerRightLegTopRigidbody.rotation, myRigidbody.rotation - 58, Time.deltaTime * lerpSpeed);
etc...
}
}
I may work to add more rotational arrangements in the same time frame to solve the problem, but of course that’s neither economic, nor pragmatic.
I really wanna say I’m open to non MoveRotation approaches, but I am so close. the only issue is the movement is just a little to fast and a little to forceful. I’m really only asking for help cause it doesn’t make sense to me this lerp function doesn’t work. for reference I call it in the update.
sorry for some reason it wont let me comment on your message
I hear you, but I’m confident if I can establish the right kind of shock absorption and the right pace of rotational movement I can get a totally fluid, adequately realistic outcome.
the first of a cycle of four rotational arrangements:
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) {
//the order will be : inner left, outer right, outer left, inner right (this is the cycle of which legs are contacting the ground when)
movingRight = true;
// lerp
if (runCycleDuration >= 0.6f) {
/*lerpingOne = true;
lerpingTwo = false;
lerpingThree = false;
lerpingFour = false;
lerpingFive = false;
lerpingSix = false;
lerpingSeven = false;
lerpingEight = false;*/
innerRightLegTopRigidbody.MoveRotation(/*lerpAngleInnerRightTopOne*/myRigidbody.rotation - 24);
innerRightLegBottomRigidbody.MoveRotation(/*lerpAngleInnerRightBottomOne*/myRigidbody.rotation - 174);
innerLeftLegTopRigidbody.MoveRotation(/*lerpAngleInnerLeftTopSeven*/myRigidbody.rotation - 104);
innerLeftLegBottomRigidbody.MoveRotation(/*lerpAngleInnerLeftBottomOne*/myRigidbody.rotation - 40);
outerRightLegTopRigidbody.MoveRotation(/*lerpAngleOuterRightTopOne*/myRigidbody.rotation - 58);
outerRightLegBottomRigidbody.MoveRotation(/*lerpAngleOuterRightBottomOne*/myRigidbody.rotation - 132);
outerLeftLegTopRigidbody.MoveRotation(/*lerpAngleOuterLeftTopOne*/myRigidbody.rotation - 158);
outerLeftLegBottomRigidbody.MoveRotation(/*lerpAngleOuterLeftBottomOne*/myRigidbody.rotation - 10);
}
this is my cyclical timer function:
void Timers() {
if (movingRight) {
runCycleDuration -= Time.deltaTime;
if (runCycleDuration < 0) {
runCycleDuration = 0.8f;
}
}
if (movingLeft) {
runCycleDurationTwo -= Time.deltaTime;
etc...
}
}
}
then this is how I tried to lerp but failed:
void LerpingOne() {
if (lerpingOne) {
lerpAngleInnerRightTopOne = Mathf.Lerp(innerRightLegTopRigidbody.rotation, myRigidbody.rotation - 24, Time.deltaTime * lerpSpeed);
lerpAngleInnerRightBottomOne = Mathf.Lerp(innerRightLegBottomRigidbody.rotation, myRigidbody.rotation - 174, Time.deltaTime * lerpSpeed);
lerpAngleInnerLeftTopOne = Mathf.Lerp(innerLeftLegTopRigidbody.rotation, myRigidbody.rotation - 104, Time.deltaTime * lerpSpeed);
lerpAngleInnerLeftBottomOne = Mathf.Lerp(innerLeftLegBottomRigidbody.rotation, myRigidbody.rotation - 40, Time.deltaTime * lerpSpeed);
lerpAngleOuterRightTopOne = Mathf.Lerp(outerRightLegTopRigidbody.rotation, myRigidbody.rotation - 58, Time.deltaTime * lerpSpeed);
etc...
}
}
I may work to add more rotational arrangements in the same time frame to solve the problem, but of course that’s neither economic, nor pragmatic.
I really wanna say I’m open to non MoveRotation approaches, but I am so close. the only issue is the movement is just a little to fast and a little to forceful. I’m really only asking for help cause it doesn’t make sense to me this lerp function doesn’t work. for reference I call it in the update.
sorry for some reason I can’t comment on your post