Okay I have been working on my first game and I was going to publish the demo. But I cant find out how to make a gun recoil and gun reload. I have the Aiming and every thing done its just what i want to do is when you reload. It takes like 2 seconds before you get your clip full. like “yield WaitForSeconds” i cant use that because I put it in function Upate…
and I am using java…
thanks
-Logan
It is difficult to help you without seeing your script One simple way around the Update() issue and waiting for a reload is to have a boolean value 'isReloading' used as a flag, and the have it set and cleared in a coroutine. In Upadate() you only allow the gun to fire if the isReloading flag is false,
public var reloading : boolean; //Are we reloading?
public var reloadTime : float; //Time it takes to reload.
private var reloadTimer : float; //Var that keeps track of time.
function Update()
{
//If we press reload and we aren't already reloading...
if (!reloading && Input.GetButtonDown("ReloadButton"))
{
reloading = true; //Start reloading.
reloadTimer = Time.time + reloadTime; //Set time to stop reloading.
}
//If we're reloading and the current time is more than the stop time...
if (reloading && Time.time > reloadTimer)
{
reloading = false; //Stop reloading.
}
}
It is difficult to help you without seeing your script One simple way around the Update() issue and waiting for a reload is to have a boolean value 'isReloading' used as a flag, and the have it set and cleared in a coroutine. In Upadate() you only allow the gun to fire if the isReloading flag is false,
– robertbudo you have reload animation for your weapon and (for recoil )is your weapon is semi automatic or full auto(ie pistol or assualt rifle)
– deltamishit is a full auto and I dont want to post my script because its over 900 lines
– logang