Flashlight - Bug/Fix Question

The place to discuss all things Receiver.
Post Reply
DrunkenPuppy
Posts: 2
Joined: Wed Jan 13, 2010 6:31 am

Flashlight - Bug/Fix Question

Post by DrunkenPuppy » Sat Nov 24, 2012 12:33 pm

I recently came across an issue where if you had a flashlight in your inventory you could still pick up another flashlight. You would then be stuck with 2 flashlights.

Looking at the AimScript, I created a simple script addon for the ability to drop the flashlight that you are holding (while your gun is holstered).

I ran into an issue with the flashlight colliding with the map. When dropped, sometimes it collides and sometimes it does not, being fairly new to unity I am not quite sure how to solve this issue. Anyone have any ideas?

Here is the code I threw in:

Code: Select all

	if(Input.GetButtonDown("Eject/Drop")){
		if(holder.has_flashlight)
		{
			if(gun_instance){
				return false;
			}
			held_flashlight.AddComponent(Rigidbody);
			held_flashlight.GetComponent(FlashlightScript).TurnOff();
			held_flashlight = null;
			holder.has_flashlight = false;
		}
	}
Criticism on code accepted!

Post Reply