LoginSignup
1
2

More than 5 years have passed since last update.

カメラの横移動とオブジェクトを中心に回転

Posted at
CameraMove.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraMove : MonoBehaviour
{

    int Mode;
    public GameObject camera;
    public float angle = 10f;
    private Vector3 targetPos;
    public Transform target;
    public float speed = 1.0f;


    void Start()
    {

        Mode = 1;

    }

    // Update is called once per frame
    void Update()
    {

        Mode = 1;

        switch (Mode)
        {
            case 0:
                camerayokoidou();
                break;


            case 1:
                camerakaiten();
                break;
        }
    }



void camerayokoidou()
    {
        camera.transform.position += new Vector3(5, 0, 0);
    }
void camerakaiten()
    {
        transform.LookAt(target);
        Vector3 axis = transform.TransformDirection(Vector3.up);
        transform.RotateAround(target.position, axis, speed*0.01f);

    }
}

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2