- Home /
Question by
AusAndrew19 · Sep 02, 2012 at 07:49 AM ·
3rd person controller
How to add "strafe" to default 3P controller?
Hi Guys.
How would i make the Basic "Original 3rd Person Controller" have strafe left and right? My Character has Animations for these but i do not understand how to call for a animation does anyone have a script with this in it? Or anyway to add this to the script. thanks.
EDIT: Also.. Strafe left "Q" Strafe Right "E"
Comment
Best Answer
Answer by grimmdev · Sep 02, 2012 at 08:13 AM
depending on your rotation, you could possibly use a simple solution to detect if key is pressed on keyboard then use transforms translate. Assuming your transform(player) if pointing vector forward and rotating then you can easily do something like this. C#
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Transform player;
void Update() {
if (Input.GetKeyDown("Q"))
player.Translate(1f,0,0);
if (Input.GetKeyDown("E"))
player.Translate(-1f,0,0);
}
}
Should be something like that if im not mistaken.