public Transform b;
transform.RotateAround (b.position, Vector3.down, Input.GetAxis ("Vertical") * 15 * Time.deltaTime);
this is different to my other thread about this as I discovered it has nothing to do with the object being a child object as I separated it from its parent and the problem still persisted. basically it’s not rotating around the point, although it is rotating around its own axis it would appear. just wonder what I’m doing wrong, thanks
What is your expected behaviour?
When I run similar code, I get a behaviour in accordance to what I expect.
I created a scene with a sphere and a cube placed arbitrarily. On the cube I place a script that does effectively what you just posted:
using UnityEngine;
public class RotateAroundExample : MonoBehaviour {
public Transform target;
public float speed = 20f;
void Update ()
{
this.transform.RotateAround(target.position, Vector3.down, Input.GetAxis("Vertical") * speed * Time.deltaTime);
}
}
I attached this to the cube, referenced the sphere in the ‘target’ field, and played.
When I pressed up or down, the cube moved as such:
lordofduct:
What is your expected behaviour?
When I run similar code, I get a behaviour in accordance to what I expect.
I created a scene with a sphere and a cube placed arbitrarily. On the cube I place a script that does effectively what you just posted:
using UnityEngine;
public class RotateAroundExample : MonoBehaviour {
public Transform target;
public float speed = 20f;
void Update ()
{
this.transform.RotateAround(target.position, Vector3.down, Input.GetAxis("Vertical") * speed * Time.deltaTime);
}
}
I attached this to the cube, referenced the sphere in the ‘target’ field, and played.
When I pressed up or down, the cube moved as such:
for me, it doesn’t rotate around the transform. when I move the transform, he still rotates around the exact same point
Can you show us? Maybe record it in action and upload? Because so far your description is not giving me an idea of what is actually happening…
Also, what does your full code look like, you only show a snippet.
Can you recreate in a small ‘test’ project (like I do here with the cube and sphere)?
1 Like