- Home /
Question by
dhanyfling · Jan 28, 2020 at 05:43 PM ·
transformrotateanimateboneweights
Animate the Bone with Code
I use script to animate bone, let say I want to rotate the bone 90 degrees within 2 second, but my script not produce animated bone but instant rotated bone, can anyone fix it ? this is my current code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoneAccess : MonoBehaviour
{
public Transform bone;
// Start is called before the first frame update
void Start()
{
bone = GetComponent<Transform>().Find("MakeHuman default skeleton/root/spine05/spine04");
}
// Update is called once per frame
void Update()
{
if(bone != null) {
bone.localEulerAngles = new Vector3 (130, 0, 0);
}
else {
Debug.Log("bone is null!");
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612222252im_/https://answers.unity.com/themes/thub/images/avi.jpg)