Skip to main content

Posts

Showing posts with the label rotation

Limiting Rotation of an Object

I made this script for my Beach Defender Game . It was to keep the player from rotating more than I want his to, because I'm a mean person like that. Any way it took me awhile to figure out how to not make them turn to far to the left, right, up, down.. You know. Here's the script. Pretty simple. Put under Update function. Feel free to suggest different ways. Or ask any questions. var upDown = Input.GetAxis("Vertical") *Time.deltaTime * (rotateSpeed-10); var leftRight = Input.GetAxis("Horizontal") * Time.deltaTime * (rotateSpeed-10); //making it turn up or down if(transform.localEulerAngles.x < 25 ){ transform.Rotate(upDown, 0, 0); } else if (transform.localEulerAngles.x > 295){ transform.Rotate(upDown, 0, 0); } //making it turn left or right if(transform.localEulerAngles.y < 65 ){ ...

Adding Inaccuracy To Shooting

Let's say you have a shooter game and its just plain to hard. Your Enemies are perfect shots and can hit you straight on every time. Making the game a little more fair would be nice, and one way doing so is by dumbing down your enemies AI a bit, and making them a less accurate with aiming.