- Home /
Simple "E" to interact script...
I do know quite a bit with OnTriggerEnter and OnTriggerExit. But however, how would I script and event that takes place (animation + sound) when the player presses the "E" key? I have an FPS controller, and so will I need to reset the cursor position to the center of the screen in my update method, as so to select properly?
I remain doubtful until I receive guidance...
Thanks in advance!
Answer by slayer29179 · Feb 18, 2013 at 09:44 PM
I don't know as part of the resetting the cursor but to make the E key animation and sound you could use:
var yourSound : AudioClip;
if (Input.GetKey("e"))
{
animation.Play(yourAnimation);
audio.PlayOneShot(yourSound);
}
Hope this gives you some guidance :)
Yes, only problem is I want it to play the animation of the object that the camera is aimed at, and I don't know how to do that...
Thanks for the good help!
Oh, you need to look up raycast to see which object is being hit :)
Excellent, thank you very much indeed! See you more around the forums!