- Home /
Character lung forward for attack?
What would be the best script for having my character lung forward for an attack? I tried using transform.Translate, but then the player didn't collide with objects. Also I should note I'm not using any imported animations, the "player" is just a cube :P
Answer by Whimsical · Jul 24, 2010 at 06:58 PM
Your problem with transform.Translate is that you only put your character on a all-new position. There's absolutely no collision detection applied, you only "beam" to the new position. One way to solve this, given you use a CharacterController, is to use CharacterController.SimpleMove(). It takes a direction and a speed and moves your character to the new position and still applies to collisions. See here for more infos. In case you work with a RigidBody instead of a CharacterController you have a few other options: RigidBody.AddForce() and RigidBody.AddExplosionForce(). More infos here.
Your answer
Follow this Question
Related Questions
Ensuring that a button is released before checking that it's pressed? 2 Answers
Quick Attack/Heavy Attack on Same Input 1 Answer
Multiple Animations, Please Help 1 Answer
I have two errors can someone help me out 1 Answer
Is there a way to do different things depending on whether the button is being held or tapped? 2 Answers