- Home /
Question by
sajattack · Oct 15, 2012 at 08:43 PM ·
instantiatepositiontransform.position
Instantiate Position Won't Change
I'm working on a game where a player is supposed to drop a bomb at their feet. I'm using transform.position in the instantiation code to make sure it goes where the player is. For whatever reason, although the same script is reporting changes in transform.position with a Debug.Log, the bomb always goes to the same spot.
Here is my code (modified code from the fps tutorial):
var bomb : Rigidbody;
var reloadTime = 0.5;
private var lastShot = -10.0;
function Fire () {
// Did the time exceed the reload time?
if (Time.time > reloadTime + lastShot && PowerHandler.instance.bombCount > 0) {
// create a new bomb, use the same position and rotation as the player.
var bomb : Rigidbody = Instantiate(bomb, transform.position, transform.rotation);
// Ignore collisions between the bomb and the character controller
Physics.IgnoreCollision(bomb.collider, transform.root.collider);
lastShot = Time.time;
PowerHandler.instance.bombCount--;
Debug.Log(transform.position);
}
}
Comment
Best Answer
Answer by sajattack · Oct 17, 2012 at 10:01 PM
I figured it out. There was an animation applied to the bomb that forced it to move to the same spot every time.
Answer by MountDoomTeam · Oct 15, 2012 at 09:22 PM
write bomb.transform.position = vector3(1.2.3); the pos u want