Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Moving Camera from point A to B progressively by Translate. It doesn't work.

Discussion in 'Scripting' started by danielapix, Feb 15, 2015.

  1. danielapix

    danielapix

    Joined:
    Feb 15, 2015
    Posts:
    7
    Good morning. Perhaps this question is stupid and not understandble cause I'm not English and I'm a unity beginner who has started to create his very first game on his own, so I'm sorry for it. In my game I need to translate the camera from a starting position to another one descripted by a Game Object in the scene as reference, losing the distance between player and camera set at start. I found the solution in directly manipulating the coordinates per frame, but the result is very difficult to understand and inefficient not at all. So, I'm trying to use the Translate function calling it just a time at section.

    The translation happens when the player collides with an invisible cube whose child is the GameObject Camera reference created in Unity.

    Here is the problem. I realized the translation relative to Space.World manipulates the world coordinates, that are inizialized with the object which script referred to. To describe the trajectory, I have thought of inserting the difference between the object's coordinates and the reference object's ones in the first argument. It doesn't work, moving the camera differently from the direction I want. What is wrong with this function I can't understand?
     

    Attached Files:

  2. navivanuva

    navivanuva

    Joined:
    Oct 10, 2014
    Posts:
    25
    danielapix likes this.
  3. danielapix

    danielapix

    Joined:
    Feb 15, 2015
    Posts:
    7
    Really tenks. If I had discovered this method before, i would have saved a lot of time.
     
  4. navivanuva

    navivanuva

    Joined:
    Oct 10, 2014
    Posts:
    25
    Ur welcome, I had the same problem too before :)