I am trying to stop a turret from rotating once the rotational limit is reached. Not sure how to use the EventType.Ignore as I am a total noob (but a fast study) to scripting in general. Any help is much appreciated. Thanks.
asked Dec 24 '09 at 01:20 PM
All clamping does is ensure that the value is in a certain range. Synopsis:
Mathf.Clamp(sourcevalue, min, max)
and it returns the clamped value. Examples:
As long as you do the clamp before the end of the frame (say, before you return from your Update() method), the player will never see the gun rotated outside of its limit. The drawback of doing it this way is that if you want to create some kind of feedback to tell the player that the gun won't rotate any more, you will need to write (a little) more code for that.
Hope this helps!
answered Dec 25 '09 at 02:33 AM
it sounds like your approach is:
i think the better approach might be:
this way you're not ignoring user input and don't have to worry about not ignoring it once they let up on that key. you can also use that continued "bad" input to alert the player they've reached the turn limit on the gun by playing a small sound of some kind (gear grinding noise for example) to let them know they can't turn anymore.
answered Dec 24 '09 at 03:30 PM
guys are right about current problem but if you want to ignore input in any other situation you can define a bool variable in your component and when you want to ignore input set it to true and when you don't want to ignore set it to false. then in your input code check the status of that variable. see this small piece of C# code
answered Dec 25 '09 at 04:40 AM