- Home /
Problem is not reproducible or outdated
looting an item
how about a looting script or parenting an object to the player.. ex. you have an object in front of you then when you step on it, something will appear on the screen then when you press F you can have the object..
the "something will appear on the screen" is just an option i can do that. the main question is how can you have that object?
Answer by LightSource · Mar 08, 2013 at 10:23 PM
Updated:
var loot : GameObject;
var near : boolean = false
function OnCollisionEnter (loot : player) {
Debug.Log("You are stepping on an object, press F to pick it up");
near = true;
}
function OnCollisionExit (loot : player) {
near = false;
}
function Update {
if (Input.GetKeyDown ("F") && near == true) {
//Do stuff
}
}
They mean that you have to put in what it's going to do. What do you want to have happen when you're standing on it.
you decide that, example for picking up..... a key, "Do stuff" shoud be replaced like keys += 1. if you don't know what += means it's exactly the same as key = key + 1 for example
I mean do what ever you want your player to do. It could be play sound, destroy the object, start an animation, it's for you to add script to do what ever you want your player to do. We can't write the whole script for you, we don't even know what your game is. You will see variations of this in alot of scripts as to give a nudge in the right direction.
DO STUFF ! $$anonymous$$ake it Happen !! Very clear !!!
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Swapping Weapons In Game 0 Answers
Make it Spawn 1 Cube instead of infenity 1 Answer
Gun swap through pickup? 2 Answers