Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Posts
    1

    Path Definition (2d game platforms)

    I am working on the 2d unity videos, I have gotten a little stumped though. I have included the generated error that Unity throws to me. I'm not quiet sure what the problem is. I want to say it's supposed to be finding my other script, PathDefinition, but is failing to do so.


    Any help would be appreciated and thank you for taking the time to help.
    Code:
    Assets/code/followPath.cs(14,16): error CS0246: The type or namespace name `PathDefinition' could not be found. Are you missing a using directive or an assembly reference?
    Code:
    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    
    public class followPath : MonoBehaviour 
    {
    	public enum FollowType
    	{
    		MoveTowards,
    		Lerp
    	}
    
    	public FollowType Type = FollowType.MoveTowards;
    	public PathDefinition Path;
    	public float Speed = 1;
    	public float MaxDistanceToGoal = .1f;
    
    	private IEnumerator<Transform> _currentPoint;
    
    	public void Start()
    	{
    				if (followPath == null) {
    						Debug.LogError ("Path cannot be null", GameObject);
    						return;
    				}
    
    				_currentPoint = Path.GetPathEnumerator ();
    				_currentPoint.MoveNext ();
    		}
    }

  2. #2
    Join Date
    Aug 2011
    Location
    Kansas
    Posts
    181
    Is PathDefinition public? Or do you maybe need another Using at the top?

  3. #3
    Join Date
    Apr 2013
    Posts
    10
    public PathDefinition Path; ---> correct is public PathDefinition followPath;

    public void Start()
    {
    if (followPath == null) {
    Debug.LogError ("Path cannot be null", gameObject);
    return;
    }

    _currentPoint = followPath.GetPathEnumerator ();
    _currentPoint.MoveNext ();
    }

  4. #4
    Join Date
    Sep 2003
    Posts
    100
    Some of your code is different from what the video says to do. I'm going through the same tutorial. My code goes through without errors.

    Right below your public void Start()
    you have if (followPath == null) {

    this is what I have:
    if (Path == null)


    Here is what I have.
    Code:
    public class FollowPath : MonoBehaviour 
    {
    	public enum FollowType
    	{
    		MoveTowards,
    		Lerp
    	}
    
    	public FollowType Type = FollowType.MoveTowards;
    	public PathDefinition Path;
    	public float Speed = 1;
    	public float MaxDistanceToGoal = .1f;
    
    	private IEnumerator<Transform> _currentPoint;
    
    	public void Start()
    	{
    		if (Path == null)
    		{
    			Debug.LogError("Path cannot be null", gameObject);
    			return;
    		}
    
    		_currentPoint = Path.GetPathEnumerator();
    		_currentPoint.MoveNext();
    Last edited by hotsauce; 11-10-2014 at 06:58 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •