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

'Transform' does not contain a definition for 'DORotate'... requires a receiver of type 'Rigidbody'

Discussion in 'Editor & General Support' started by RickBGove, Feb 6, 2021.

  1. RickBGove

    RickBGove

    Joined:
    Jan 9, 2021
    Posts:
    8
    I'm trying to get a camera that will rotate around my GameObject infinitely using DoTween.

    Here is my C# code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using DG.Tweening;
    5.  
    6.  
    7. public class CameraRotator : MonoBehaviour
    8. {
    9.  
    10.     public float speed;
    11.  
    12.     void Update()
    13.     {
    14.         // transform.Rotate(0, speed * Time.deltaTime, 0);
    15.         transform.DORotate((0,360,0), 2f, RotateMode.Fast).SetLoops(-1).SetEase(Ease.Linear);
    16.     }
    17. }
    18.  
    and here is the error:
    Assets/CameraRotator.cs(15,9): error CS1929: 'Transform' does not contain a definition for 'DORotate' and the best extension method overload 'DOTweenModulePhysics.DORotate(Rigidbody, Vector3, float, RotateMode)' requires a receiver of type 'Rigidbody'

    I know this is very vague, I'm new to Unity and I don't know what other information people might need to help me... I can tell you whatever else you need to know about my project, just ask...
     
  2. sanercakir

    sanercakir

    Joined:
    Dec 24, 2020
    Posts:
    2
    try this instead of the (0, 360,0):

    new Vector3(0, 360,0)
     
  3. AikIsHere

    AikIsHere

    Joined:
    Oct 1, 2015
    Posts:
    1
    hello this is too late but I know your case which is also my case.
    It is a very bad hint.

    Just put an "f" to all of your float parameters then it will be OK
    I my case,
    transform.DOShakeRotation(0.4f, new Vector3(0, 5, 0), 5);
    is good while
    transform.DOShakeRotation(0.4, new Vector3(0, 5, 0), 5);
    gives me
    'Transform' does not contain a definition for 'DOShakeRotation'

    just hope help others
     
    rockyn likes this.