|
I wrote this simple script to an i-pad game in which my Player should pick-up automatically apples (when Player and apple enter in touch) from the floor and add points to the score for that. I attached it as a this separate script to my Player and checked the Trigger marks, both in the apple and the Player. Although the easy this seems, the apple do not disappears; that is, I missed something I can't find. Any help, please.
} @script RequireComponent(AudioSource)
(comments are locked)
|
|
Probably you need to add a rigidbody to one or both of the objects. From the documentation for Box Collider:
The same is true for the other collider types. That was the problem: I forgot to add a rigidbody to the apples prefab. Thanks a lot! Also thanks to Toxic Blob!
Apr 18 '11 at 07:23 PM
pepefirst
(comments are locked)
|

As you have an if statement, can you confirm that the tag check is working? Does appleCollect.points increase as you touch the apples?
Also, on the iPad you want to avoid using Destroy as that causes garbage collection and memory reallocation. It's better to simply disable the apple, then re-enable it when needed elsewhere.
Sorry Toxic Blob, I made an edit to my post after your answers because I got a Unity error message with Collision Points; I changed it by var points. I have not implemented yet the Scorer script but I suppose it will not work either because I do not get the pick-up sound.
Try below points++ adding "Debug.Log("collision with an apple");. If you don't get that then either the tag comparison is failing, or you need a rigidbody as Bampf suggests below