hover and follow player AI

Greetings…

im trying to get a drone companion (simple sphere) to hover around with slight bob and follow my player (i attached an empty game object offset the dudes shoulders)
.

ive got two scripts that dont like each other but when used alone have the desired effect , ive tried to mash the two together with out success
.

the hover script is smooth and bobs up and down on y axis nicely (with options) so id love to use it for the drones idle
.
the follow script has the drone follow and catch up part, how can i get these two to work together , thank you

hover script

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

public class HoverDrone : MonoBehaviour
{
    public Vector3 bobAmount, rotateAmount, bobSpeed, rotateSpeed;
    private Vector3 startPos, startRot, targetPos, targetRot;

    void Start()
    {
        startPos = transform.localPosition;
        startRot = transform.localEulerAngles;
    }

    void Update()
    {
        targetPos = new Vector3(startPos.x + (bobAmount.x * Mathf.Sin(Time.time * bobSpeed.x)),
                                startPos.y + (bobAmount.y * Mathf.Sin(Time.time * bobSpeed.y)),
                                startPos.z + (bobAmount.z * Mathf.Sin(Time.time * bobSpeed.z)));

        targetRot = new Vector3(startRot.x + (rotateAmount.x * Mathf.Sin(Time.time * rotateSpeed.x)),
                                startRot.y + (rotateAmount.y * Mathf.Sin(Time.time * rotateSpeed.y)),
                                startRot.z + (rotateAmount.z * Mathf.Sin(Time.time * rotateSpeed.z)));

        transform.localEulerAngles = targetRot;
        transform.localPosition = targetPos;
    }
}

follow player script

using UnityEngine;



    public class FollowTargetAI : MonoBehaviour
    {
    public float MinDistance = 3;
    public float MaxDistance = 1;
    public float Speed = 3;
    public Transform Player;


    void Update()
    {
        //transform.LookAt(Player);
        if (Vector3.Distance(transform.position, Player.position) >= MinDistance)
        {
            Vector3 follow = Player.position;
          
            follow.y = this.transform.position.y;
           
            this.transform.position = Vector3.MoveTowards(this.transform.position, follow, Speed * Time.deltaTime);
        }
    }
}

Hey @GreenTraveler ,

It’s not working because both scripts are modifying the transform of the drone.

I made this work by adding the bob script to the target object, and the follow script to the drone.

Good luck!