Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Global space - directions are constant, we move relative to the plane. Rotate object - still the same
- (upper tab above scene)
- Local space- directions are based upon the orientation of the cube
- Drag sphere object onto Cube in the hierarchy
- cube is parent of sphere
- New C# script attach to cube object. Call it cube script
- public Transform sphereTransform
- >attach sphere to transform
- void Start(){
- sphereTransform.parent = transform;
- }
- void Update(){
- transform.eulerAngles += new Vector3(0, 100 * Time.deltaTime, 0);
- >>>>transform.eulerAngles += new Vector3(0, 1, 0) * Time.deltaTime;
- >>>>Vector3.up * 180 * Time.deltaTime
- }
- Rotate cube 45 degrees and press play
- void Update(){
- transform.Rotate(Vector3.up * Time.deltaTime * 180);
- }
- now rotating about the local y axis
- back to global
- void Update(){
- transform.Rotate(Vector3.up * Time.deltaTime * 180, Space.World);
- transform.Translate (Vector3.forward * Time.deltaTime * 7);
- }
- Now it starts moving forward. If we add Space.World, it moves to global space and moves forward forever
- void Start(){
- sphereTransform.localScale = new Vector3 (2, 2, 2);
- }
- or
- void Start(){
- sphereTransform.localScale = Vector3.one * 2;
- }
- void Update(){
- if (Input.GetKeyDown(KeyCode.Space){
- sphereTransform.position = Vector3.zero;
- }
- }
- Why does it do this? It resets the position back to zero
- instead
- sphereTransform.localposition = Vector3.zero;
Advertisement
Add Comment
Please, Sign In to add comment