- Home /
 
 
               Question by 
               kaiserium16 · Jun 25, 2019 at 02:09 PM · 
                camerascript.vector3camera-lookoffset  
              
 
              How do you change the values of Vector3 Offset (x, y, z) in script randomly/overtime?
Hi there!
I am a beginner coder and currently have a camera script which tracks the player:
using UnityEngine; public class camera : MonoBehaviour {
 public Transform target;
 public float smoothSpeed = 0.125f;
 public Vector3 offset;
 void LateUpdate ()
 {
     Vector3 desiredPosition = target.position + offset;
     Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed * Time.deltaTime);
     transform.position = smoothedPosition;
     transform.LookAt(target);
 }
 
               }
I want the values of Vector3 (x, y, z) to randomly change in value overtime in script so the camera re-maneuvers itself around the player. So for instance like every 10 seconds the values of x, y, z randomize between a value of let's say -5 and 5 ie. (2, 3, -2), (-1, 4, 5). Does anyone know how this can be done in script?
Thank you :)
               Comment
              
 
               
              Your answer