Search Unity

Camera Offset + Rotate Around

Discussion in 'Scripting' started by Anthony0506, Feb 20, 2018.

  1. Anthony0506

    Anthony0506

    Joined:
    Jan 2, 2018
    Posts:
    22
    When I try to combine the offset script

    Start() {

    offset = transform.position - player.transform.position; }

    update(){
    transform.position = player.transform.position + offset;}


    with the RotateAround script


    update(){
    if(Input.GetKeyUp ("[")) { transform.RotateAround player.transform.position, new Vector3(0.0f, 1.0f, 0.0f), 90.0f); } }



    transform.Rotate

    Around (player.transform.position, new Vector3(0.0f, 1.0f, 0.0f), 90.0f);



    it doesn't work, as it rotates oddly. is there a way to work these scripts together, without having to get into quaternions?

    this exact qauestion was asked in this reddit thread but i couldn't get his solution to work.

    can anyone help me to understand this better?

    https://www.reddit.com/r/Unity3D/co...object_follow_object/?st=jdty6of5&sh=f45a7d90