Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2011
    Posts
    6

    Exclamation TP_Controller Implementation video Script ERROR

    i get these errors:
    Code:
    Assets/Scripts/TP_Controller.cs(38,68): error CS0019: Operator `<' cannot be applied to operands of type `method group' and `float'
    
    Assets/Scripts/TP_Controller.cs(35,66): error CS0019: Operator `<' cannot be applied to operands of type `method group' and `float'
    in this script:
    Code:
    using UnityEngine;
    using System.Collections;
    
    public class TP_Controller : MonoBehaviour {
    
    	public static CharacterController CharacterController;
    	public static TP_Controller Instance;
    	public static  bool Active = false;
    	
    	// Use this for initialization
    	void Awake () 
    	{
    		CharacterController = GetComponent("CharacterController") as CharacterController;
    		Instance = this;
    	}
    	
    	// Update is called once per frame
    	void Update () 
    	{
    		if(Camera.mainCamera == null)
    			return;
    		if(!Active)
    			return;
    		GetLocomotionInput();
    		
    		TP_Motor.Instance.UpdateMotor();
    	}
    	
    	void GetLocomotionInput()
    	{
    		var deadZone = 0.1f;
    		
    		TP_Motor.Instance.MoveVector = Vector3.zero;
    		
    		if(Input.GetAxis("Vertical") > deadZone || Input.GetAxis < -deadZone)  //<-- Error here
    			TP_Motor.Instance.MoveVector += new Vector3( 0, 0, Input.GetAxis("Vertical"));
    		
    		if(Input.GetAxis("Horizontal") > deadZone || Input.GetAxis < -deadZone) //<-- And here
    			TP_Motor.Instance.MoveVector += new Vector3( Input.GetAxis("Horizontal"), 0, 0);
    	}
    }
    from the TP_Controller Implementation video tutorial in the unity 3d Simple Character System chapter
    please help

  2. #2
    Join Date
    Sep 2008
    Location
    Salisbury, UK
    Posts
    2,812
    Code:
    if(Input.GetAxis("Vertical") > deadZone || Input.GetAxis < -deadZone)
                TP_Motor.Instance.MoveVector += new Vector3( 0, 0, Input.GetAxis("Vertical"));
            
            if(Input.GetAxis("Horizontal") > deadZone || Input.GetAxis < -deadZone)
                TP_Motor.Instance.MoveVector += new Vector3( Input.GetAxis("Horizontal"), 0, 0);
        }
    should be
    Code:
    if(Input.GetAxis("Vertical") > deadZone || Input.GetAxis("Vertical") < -deadZone)
                TP_Motor.Instance.MoveVector += new Vector3( 0, 0, Input.GetAxis("Vertical"));
            
            if(Input.GetAxis("Horizontal") > deadZone || Input.GetAxis("Horizontal") < -deadZone)
                TP_Motor.Instance.MoveVector += new Vector3( Input.GetAxis("Horizontal"), 0, 0);
        }

    I found
    my current avatar on google, so props to THIS GUY who created the original...

  3. #3
    Join Date
    Mar 2011
    Posts
    6

    Exclamation thanks

    Quote Originally Posted by fatgav View Post
    Code:
    if(Input.GetAxis("Vertical") > deadZone || Input.GetAxis < -deadZone)
                TP_Motor.Instance.MoveVector += new Vector3( 0, 0, Input.GetAxis("Vertical"));
            
            if(Input.GetAxis("Horizontal") > deadZone || Input.GetAxis < -deadZone)
                TP_Motor.Instance.MoveVector += new Vector3( Input.GetAxis("Horizontal"), 0, 0);
        }
    should be
    Code:
    if(Input.GetAxis("Vertical") > deadZone || Input.GetAxis("Vertical") < -deadZone)
                TP_Motor.Instance.MoveVector += new Vector3( 0, 0, Input.GetAxis("Vertical"));
            
            if(Input.GetAxis("Horizontal") > deadZone || Input.GetAxis("Horizontal") < -deadZone)
                TP_Motor.Instance.MoveVector += new Vector3( Input.GetAxis("Horizontal"), 0, 0);
        }
    thanks but now i encountered a feww errors in the TP_Motor Script

    Code:
    Error 1: Assets/Scripts/TP_Motor.cs(36,31): error CS0103: The name `deltaTime' does not exist in the current context
    
    Error 2: Assets/Scripts/TP_Motor.cs(47,106): error CS1061: Type `UnityEngine.Camera' does not contain a definition for `eulerAngles' and no extension method `eulerAngles' of type `UnityEngine.Camera' could be found (are you missing a using directive or an assembly reference?)
    
    Error 3: Assets/Scripts/TP_Motor.cs(47,57): error CS1502: The best overloaded method match for `UnityEngine.Quaternion.Euler(float, float, float)' has some invalid arguments
    
    Error 4: Assets/Scripts/TP_Motor.cs(47,57): error CS1503: Argument `#2' cannot convert `object' expression to type `float'
    the Script:

    Code:
    using UnityEngine;
    using System.Collections;
    
    public class TP_Motor : MonoBehaviour {
    
    	public static TP_Motor Instance;
    	
    	public float MoveSpeed = 10f;
    	
    	public Vector3 MoveVector { get; set; }
    	
    	void Awake () 
    	{
    		Instance = this;
    	}
    	
    	public void UpdateMotor () 
    	{
    		SnapAlignCharaterWithCamera();
    		ProcessMotion();
    	}
    	
    	void ProcessMotion()
    	{
    		//transform MoveVector
    		MoveVector = transform.TransformDirection(MoveVector);
    		
    		//Normalize MoveVector
    		if(MoveVector.magnitude > 1)
    			MoveVector = Vector3.Normalize(MoveVector);
    		
    		//Multiply MoveVector by MoveSpeed
    		MoveVector *= MoveSpeed;
    		
    		// Multiply MoveVector by Deltatime
    		MoveVector *= deltaTime; // <-- Error 1
    		
    		//Move Charater in world
    		TP_Controller.CharacterController.Move(MoveVector);
    		
    	}
    	
    	void SnapAlignCharaterWithCamera()
    	{
    		if(MoveVector.x != 0 || MoveVector.z !=0)
    		{
    			transform.rotation = Quaternion.Euler(transform.eulerAngles.x, Camera.mainCamera.eulerAngles.y, transform.eulerAngles.z); //<-- Error 2,3, AND 4
    			
    		}
    	}
    }
    i hope you could help me with this too

  4. #4
    Join Date
    Sep 2008
    Location
    Salisbury, UK
    Posts
    2,812
    From the other thread...
    Quote Originally Posted by fatgav View Post
    Given that these are basic errors of omission - identical in nature to those I answered in your previous thread - I think you ought to be able to solve these given the following hints: Where you see, for instance, "Error n: Assets/Scripts/Blah.cs(47,57): error ...", the 47 means LINE NUMBER 47 of Blah.cs (the 57 means the 57th character in that line, btw). Another viewing of the videos should also enable you to compare what you've input to Lee's code, and thus find these errors. This process (debugging) is a tedious but necessary skill to develop if you want to improve as a programmer...
    It really is gonna be of more benefit to you if you can learn to spot these kinds of errors than for me to just tell you; particularly from the standpoint of interpreting what Unity's messages indicate, as you don't have the option of utilising VS's breakpoints, etc. from inside Unity...

    I found
    my current avatar on google, so props to THIS GUY who created the original...

  5. #5
    Join Date
    Mar 2011
    Posts
    6
    thanks, i solved this by my self but thanks for the tips...
    i'm not that good with C# yet so i tend to make silly mistakes , i usually use JavaScript

  6. #6
    Join Date
    Sep 2008
    Location
    Salisbury, UK
    Posts
    2,812
    That's great, good job.

    I found
    my current avatar on google, so props to THIS GUY who created the original...

  7. #7
    Join Date
    Mar 2011
    Posts
    6
    yea i tried using this control setup in a multilayer game, it works perfectly with juss one player but when another player is added the controls control the other player and when that player leaves control is lost altogether.
    do you have any tips

Posting Permissions

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