Hi, I'm sure similar questions have been asked but please bare with me as I'm new!
I'm creating an FPS game and require the ability to pick up items. I've heard the use of raycasts but I'm not sure how to script this. I'm hoping to make it so that when the character is in proximity of the object, or looking at it within proximity (whichever makes more sense) from them to pick it up so it is no longer there.
Additionally to this, I want there to be objects that can be opened only if the item required has already been picked up.
Any help would be greatly appreciated!
I tried the following code but it isn't working, any ideas? (I have a box collider on the object I want to interact with)
PS.I attached that script to the Main Camera within the First Person Controller.
That's for raycasts...
I'd personally do an if statement, check the distance between the item and the player, and then do another if in that if to check if the player has it, if he does, output it to screen, if he doesn't, then have it Destroy, then put it in his inventory...
I don't know much about raycasts, so I'd wait for someone more intelligent on that to post an answer, but I hoped I steered you a little bit =).
answered Dec 05 '10 at 03:13 PM