- Home /
Rotate children (Cards) on a panel (maybe using lerp, or another method?)
Unable to get this to work
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LerpCards : MonoBehaviour {
float lerpValue = 0f;
float increment;
private void Update()
{
increment = 1f / transform.childCount;
Quaternion q1 = Quaternion.AngleAxis(150f, Vector3.forward);
Quaternion q2 = Quaternion.AngleAxis(30f, Vector3.forward);
foreach (Transform child in transform)
{
lerpValue += increment;
child.rotation = Quaternion.Lerp(q1, q2, lerpValue);
}
}
}
Answer by RkTheGuy · May 29, 2017 at 06:36 AM
If it's a simple rotation you are trying to achieve, the code is good and should be working. Try reducing the value of the increment to (say) increment = 0.01f/transform.childCount;
The problem maybe that your effect is too fast and it gets finished even before you see it.
If the problem is something else, please try to be more precise and write what you are trying to do and what the problem is.. next time
Cheerio!
Your answer
Follow this Question
Related Questions
How to ROTATE an object without slowing the ends (lerp) 3 Answers
Lerp 180 degrees while holding B and lerp back 180 degrees when let go of B. 2 Answers
Clamped Turret Doesn't Want to Lerp the Other Way 2 Answers
How to make a gameobject have a rotation constraint? 1 Answer
Adding Rotation to a Gameobject 1 Answer