Hello sirs and madames,
2 issues that to me seem they should not happen in a world of math and logic. But here they are.
I’m instantiating a gameobject, in this case an axe, and as I do that I push it. Below code.
Vector3 instPos = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, this.gameObject.transform.position.z);
Debug.Log(instPos);
GameObject axe = Instantiate(thrownAxe, instPos, Quaternion.identity) as GameObject;
axe.gameObject.GetComponent<Rigidbody>().AddRelativeForce(Camera.main.transform.forward * throwForce);
However.
Problem 1: The axes spawn on 2 different Y-positions. 90% of the time, roughly, in the right spot, but sometimes above. Illustrated in this picture, and my paint skills show the separate paths they travel. I would estimate roughly 1-2 Y world units difference between them.
Edit: I can’t seem to add this picture correctly, so here’s the link (Imgur: The magic of the Internet)
Problem 2: As I spam a bunch of axes in the air (because it’s fun), the ones that spawn in the correct position, they actually start spawning lower and lower and lower and lower until they spawn in the ground.
Other info:
- The script repeatedly spawning this prefab axe is put on the axe in hand you see in the picture, which is in a static position (for now) on my FPS-controller.
- There is no other mention or manipulation of the instPos vector3 in other places of the code.
I’m grateful for any help. Have a good one.
Best regards,
Tomas