- Home /
Question by
Skyline Studios · Nov 28, 2012 at 09:29 PM ·
pickupuppick
Object pick up script
So im trying to make a game like amnesia, and I want to be able to pick up a lantern (like a flashlight) so it attaches to the first person controller. Im new to Java script and C# so if anybody can help me it would be great.
Comment
Best Answer
Answer by greatestprez · Nov 29, 2012 at 05:41 PM
Put something like this in the script controlling your pick-up object (make sure the collider on it is set to isTrigger)
void OnTriggerEnter(Collider col) {
if(col.gameObject.tag == "MyTag") {
// insert code to move position of the object to right in front of the player
}
}