Search Unity

switch from a camera to a gameobject

Discussion in 'Scripting' started by chupachupss, Mar 17, 2018.

  1. chupachupss

    chupachupss

    Joined:
    Mar 4, 2018
    Posts:
    1
    Hello,

    I have a boat game.

    I have a camera that is the boat when I move it.

    I would like to go from this camera to the character I made in the first person knowing that this is a multiplayer game.

    I use unet for the multiplayer system.

    here is the code that helps move the boat forward :


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Networking;

    public class PlayerController : NetworkBehaviour {

    void Update () {

    if (!isLocalPlayer) {
    return;
    }
    var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
    var z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;

    transform.Rotate(0, x, 0);
    transform.Translate(0, 0, z);
    }
    }


    thank you in advance
     
  2. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    You could have two camers in scene and use an event or condition to swap between the two.