Instantiate with .x offset

I need to offset the transform.position.x by .5

I tried few things but i can’t figure this out.
Thank you

  	Rigidbody bPrefab = Instantiate(bulletPrefab, transform.position, Quaternion.identity) as Rigidbody;
		bPrefab.rigidbody.AddForce(Vector3.right * 100);

Got the it working like this:

  	Vector3 posOffset = transform.position;
		posOffset.x += 1.5f;
		Rigidbody bPrefab = Instantiate(bulletPrefab, transform.position, Quaternion.identity) as Rigidbody;
		bPrefab.rigidbody.AddForce(Vector3.left * 500);

1 Answer

1

You calculate posOffset, but then you don’t pass it to Instantiate()?

Looks like you want something closer to this:

Rigidbody bPrefab = Instantiate(bulletPrefab, posOffset, Quaternion.identity) as Rigidbody;

You are right rutter, i did forgot to pass it. Thank you,