- Home /
The question is answered, right answer was accepted
Problem with simple JavaScript, No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(UnityEngine.GameObject, UnityEngine.Vector3)' was found.
Problem with this script, am I just really stupid because I can't find the problem. #pragma strict
var Health : int;
var explosion : GameObject;
var target : Transform;
function DeductPoints (Damage : int) {
Health -= Damage;
}
function Update () {
if (Health <= 0) {
Destroy(gameObject);
Instantiate(explosion, target.position);
}
}
Answer by Bunny83 · Nov 14, 2017 at 02:47 AM
Instantiate basically comes in two version. The first one just takes a source object reference of the object that should be cloned. The second version takes 3 parameters: The source object, a target position and a target rotation. You only pass two parameters to the method which is not possible as you either have to pass 1 parameter or 3.
So your missing the rotation of the object. If you don't want a particular rotation you usually pass Quaternion.identity.
Instantiate(explosion, target.position, Quaternion.identity);
Follow this Question
Related Questions
How would i make it transform player.position =target.position? 2 Answers
Its not playing the Audio? 2 Answers
How to rotate a cube on its edge and have the cube able to climb up other surfaces 0 Answers
Attach to other coordinat SpringJoint2D from code. 0 Answers
When moving object, should i use transform.position or a animation clip i recorded ? 0 Answers