I want to delay the start of the cinemachine dollycart by a few seconds so I thought of adding a script to the Cart that set the m_speed to 0 waited a few seconds and then set it back to 10 (the normal speed). I have the following code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class Waiter : MonoBehaviour
{
public float waitSeconds;
// Start is called before the first frame update
void Start()
{
gameObject.GetComponent<CinemachineDollyCart>().m_speed = 0;
StartCoroutine(waiter());
gameObject.GetComponent<CinemachineDollyCart>().m_speed = 10;
}
IEnumerator waiter()
{
//Wait for x seconds
yield return new WaitForSeconds(waitSeconds);
}
}
However, VS Code marks “using Cinemachine” and
“gameObject.GetComponent()”
with error CS0246 (couldn’t find “Cinemachine” namespace).
Also when i try to play on Unity it gives the following compiler error: “Assets\Scripts\Waiter.cs(12,57): error CS1061: ‘CinemachineDollyCart’ does not contain a definition for ‘m_speed’ and no accessible extension method ‘m_speed’ accepting a first argument of type ‘CinemachineDollyCart’ could be found (are you missing a using directive or an assembly reference?)” (same for line 14).
I’ve tried deleting .csproj files and opening the project again but it doesn’t get fixed. Also I don’t know if there is an easier way to do this that doesn’t involve messing with the using Cinemachine namespace.
Unity version: 2019.3.3f1
VS Code Editor: 1.1.4
Cinemachine version: 2.5.0