So I think this is the script but I'm not sure if its legit, is it C# or JAva? publicenumDodgeDirection{Right,Left,Forward,Backward} // This vector is essential if you want to have variants dodging amounts/forces, it represents how much the player will go to the side, up and forward // left: -x, right: +x, up: +y, down: -y, forward: +z, backward: -z. Don't worry you'll understand in a moment // if you don't want to have different forces applied to your player when he dodges left/right, forward/backward, just get rid of this vector and use a float variable instead publicVector3 dodge =newVector3(5,5,5); // This is the dodging method, you just give it a direction and it will handle the rest using the `dodge` vector we previously defined. publicvoidDodge(DodgeDirection dir) { switch(dir) { caseDodgeDirection.Right: rigidbody.AddForce(_transform.right * dodge.x + _transform.up * dodge.y,ForceMode.Impulse); break; caseDodgeDirection.Left: rigidbody.AddForce(-_transform.right * dodge.x + _transform.up * dodge.y,ForceMode.Impulse); break; caseDodgeDirection.Forward: rigidbody.AddForce(_transform.forward * dodge.z + _transform.up * dodge.y,ForceMode.Impulse); break; caseDodgeDirection.Backward: rigidbody.AddForce(-_transform.forward * dodge.z + _transform.up * dodge.y,ForceMode.Impulse); break; } } // Since we're gonna be dealing with a rigidbody and forces, we might as well use FixedUpdate // I used 'l', 'j', 'i' and 'k' to dodge left, right, forward and backward (respectively) // If I were you and using WASD controls, I would dodge left by double tapping 'A', right by double tapping 'D' etc. (With a threshold I define) voidFixedUpdate() { if(Input.GetKeyDown("l")) Dodge(DodgeDirection.Right, dodge); if(Input.GetKeyDown("j")) Dodge(DodgeDirection.Left, dodge); if(Input.GetKeyDown("i")) Dodge(DodgeDirection.Forward, dodge); if(Input.GetKeyDown("k")) Dodge(DodgeDirection.Backward, dodge); }
its c# .. use the code dealy to paste it... (click icon to left of save disc icon, and pick code, paste code in there) Code (CSharp): if ( stuff = stuff) { //things }