|
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.
(comments are locked)
|
|
Try this:
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!
(comments are locked)
|
|
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. I set it up the way you suggested but I am unsure of how to restrict the transform.Rotate (x,y,z) to only one direction in the Else statement. (ie, if the turret is all the way to the right, it should be able to rotate left, but not right...)
Dec 24 '09 at 05:10 PM
Shadyfella13
(comments are locked)
|
|
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
(comments are locked)
|
