Game Development Reference
In-Depth Information
if(Input.GetKey("space"))
{
//each loop the space is down increase the strength
Camera.main.GetComponent("strengthMeter").
shotStrength =
Camera.main.GetComponent("strengthMeter").
shotStrength + 0.01;
}
if(Input.GetKeyUp ("space"))
{
var cannonball:GameObject = Instantiate(cannonball,
this.transform.position, this.transform.
rotation);
//use built up strength to influence the shot
var strength = Camera.main.
GetComponent("strengthMeter").
shotStrength * 10000;
cannonball.rigidbody.AddForce(this.transform.
up * strength);
//set strength back to 0 after a shot
Camera.main.
GetComponent("strengthMeter").
shotStrength = 0;
}
}
Step 22. Play. This time when firing, hold down the space bar to build
up the strength and then release when you think it is enough. Slider
bars used in the GUI only allow values between 0 and 1, which is why
the final strength is multiplied with the maximum allowed strength in
order to create a larger force for the cannon.
4.4.3 Racing
Racing involves one or more players attempting to get from one location
to another in order to beat the clock or beat one another. Racing is a
common sport found involving unaided human participants (in many
Olympic events), motor vehicles (such as formula 1 or drag racing),
and animals (including horses, dogs, and, on Australia Day in Australia,
cockroaches!).
Many computer games include racing in a variety of forms. Project Gotham
sees players racing around the streets of the world's cities in production
Search Nedrilad ::




Custom Search