Hi, I have a game in which you control a catapult. Currently the player can rotate the “arm” of the catapult and the game launches the projectile if the arm reaches a certain angle. However, as this is an educational momentum-based game, I need the angle of the catapult arm to affect the projectile’s velocity. To get to doing this I need the player to be able to initiate a launch sequence for the catapult arm, storing the rotation of the arm at the point of initiation so it can be used later. The problem I am having is setting up a script for launch. It needs to do the following:
- Stop accepting input from the up and down arrow keys temporarily as they affect the rotation script
- Only require the space bar to be pressed once in order to trigger the launch
- Automate the movement of the arm from whatever rotation it is at, up to the 90 degree mark
The actual trajectory of the projectile is done elsewhere and is initiated when the arm reaches the 90 degree mark in its x axis rotation.
The rotation script for the catapult arm is as follows:
var speed : float = 5.0f; // meters per second function FixedUpdate() { if(Input.GetKey ("up") && transform.rotation.eulerAngles.x < 85) { transform.rotation.eulerAngles.x += speed; } if(Input.GetKey ("down") && transform.rotation.eulerAngles.x > 10) { transform.rotation.eulerAngles.x -= speed; } }
Any help in setting up the launch sequence script would be greatly appreciated!
Many thanks to such a great community