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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Cinemachine Delay Start of DollyCart - Problem with namespace Cinemachine - VS Code

Discussion in 'Cinemachine' started by joanmuntaner1999, May 23, 2020.

  1. joanmuntaner1999

    joanmuntaner1999

    Joined:
    Aug 26, 2015
    Posts:
    2
    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:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Cinemachine;
    5.  
    6. public class Waiter : MonoBehaviour
    7. {
    8.     public float waitSeconds;
    9.     // Start is called before the first frame update
    10.     void Start()
    11.     {
    12.         gameObject.GetComponent<CinemachineDollyCart>().m_speed = 0;
    13.         StartCoroutine(waiter());
    14.         gameObject.GetComponent<CinemachineDollyCart>().m_speed = 10;
    15.     }
    16.  
    17.     IEnumerator waiter()
    18.     {
    19.         //Wait for x seconds
    20.         yield return new WaitForSeconds(waitSeconds);
    21.     }
    22. }
    However, VS Code marks "using Cinemachine" and
    "gameObject.GetComponent<CinemachineDollyCart>()"
    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
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Try m_Speed with a capital S, instead of m_speed. :)
    Code (CSharp):
    1. gameObject.GetComponent<CinemachineDollyCart>().m_Speed = 0;
     
  3. joanmuntaner1999

    joanmuntaner1999

    Joined:
    Aug 26, 2015
    Posts:
    2