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

Knockback is not compatible with the argument list '()'.

Discussion in 'Scripting' started by aaronrotc2014, Feb 20, 2015.

  1. aaronrotc2014

    aaronrotc2014

    Joined:
    Apr 17, 2014
    Posts:
    7
    how would i go about fixing it
    Code (JavaScript):
    1.      public var speed : float = 15.0;
    2.      public var duration : float = 0.25;
    3.    
    4.      private var controller : CharacterController;
    5.      function Start(){
    6.          controller = GetComponent(CharacterController);
    7.      }
    8.      function Knockback(direction : Vector3){
    9.          var startTime = Time.time;
    10.          while(Time.time < (startTime + duration)){
    11.              controller.SimpleMove(direction*speed);
    12.              yield;
    13.          }
    14.      }
    15.      function OnControllerColliderHit (hit : ControllerColliderHit) {
    16.     Knockback();
    17.     }
    18.  
     
  2. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    490
    Knockback is a function with the argument "direction", which is a Vector3. So to call Knockback you have to plug in a Vector3 as an argument, like:
    Code (JavaScript):
    1. Knockback (thisIsMyVector3Variable);
     
  3. aaronrotc2014

    aaronrotc2014

    Joined:
    Apr 17, 2014
    Posts:
    7
    what do i use for the vector 3 variable?