Player object not instantiating at where I want it to
Whenever my player gets destroyed, I want it to be instantiated at the transform.position of a specific game object, of which I have named revivePoint. I have 2 scripts and 1 game object relating to this: 1) GameDataLog.cs 2) RevivePoint game object (which has a RevivePoint.cs script) 3) PlayerController game object (which has a PlayerController.cs script) The code I have used is as follows:
At the start of the scene, I get the GameDataLog to reference the revivepoint game object
private void Awake()
{
currentRevivePointObject = FindObjectOfType<RevivePoint>();
currentRevivePoint = currentRevivePointObject.transform;
}
then whenever the player dies, there will be 0 player controller objects, hence I use the GameDataLog to initiate a series of scripts
private void Update()
{
if (FindObjectsOfType<PlayerController>().Length < 1)
{
ReviveHere(currentRevivePoint);
}
}
this calls the the ReviveHere function
public void ReviveHere(Transform reviveMeHere)
{
Instantiate(player, reviveMeHere);
}
so by right the game object should instantiate at the centre of wherever I place the revivepoint game object, as long as there is only 1 in the scene.
But the playercontroller always gets instantiated to the top right of the revivepoint for no apparent reason, which has become a problem for me making levels. I know the player controller;s revivepoint is still somewhat dependant on the revivepoint.transform as I did play around with it and the player always revives at the exact same top right position of the revivepoint.
this is just a screenshot of what im working with. I cant send a gif because of the filesize. [1]: /storage/temp/171459-screenshot-5.png
Your answer
![](https://koobas.hobune.stream/wayback/20220613020310im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Help a novice with wall jumping 1 Answer
how do i make the player dash upwards? 0 Answers
increase or decrease a value by 1 depending of current condition 0 Answers
Coroutine and Waitforseconds 1 Answer