Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJustine Knight
195 PointsObject reference problem for Fly Movement game
This error comes up: Severity Code Description Project File Line Suppression State Error CS0120 An object reference is required for the non-static field, method, or property 'Transform.RotateAround(Vector3, Vector3, float)' Assembly-CSharp-firstpass D:\Unity\How to Make a Video Game\Assets\Standard Assets\CrossPlatformInput\Scripts\FlyMovement.cs 24 Active
Below is my code for the FlyMovement, this is my second time trying it here.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class FlyMovement : MonoBehaviour {
[SerializeField]
private Transform center;
private float flySpeed;
// Use this for initialization
void Start () {
flySpeed = Random.Range(300f, 700f);
}
// Update is called once per frame
void Update () {
Transform.RotateAround(center.position, Vector3.up, angle: flySpeed * Time.deltaTime);
}
}