I would like to instantiate a platform at the same x position of my player
So i got an endless jumper , my player jumps on platforms0. when he reaches a number of coins my other platforms need to be instantiated , but at the same x.position. It doesn't really work. It got it instantiated at the good y position but my x position is 4000. So I don't understand what i did wrong , here is my code. If somebody can help me. Thankssssss
public void CreateLeftPlatform() { lastPlatformPositionY +=DISTANCE_BETWEEN_PLATFORMS;
Vector3 temp = player.transform.position ;
temp.x=player.transform.position.x ;
player.transform.position = temp;
GameObject newLeftPlatform= Instantiate(leftPlatform);
newLeftPlatform.transform.position = new Vector3(temp.x,lastPlatformPositionY,0);
newLeftPlatform.name = "LeftPlatform" + countPlatforms;
countPlatforms ++;
theCoinGenerator.SpawnCoins(new Vector3(newLeftPlatform.transform.position.x,lastPlatformPositionY +1,newLeftPlatform.transform.position.z));
}
Your answer
Follow this Question
Related Questions
Instantiating at a specific location? 0 Answers
How to Instantiate platforms with certain space inbetween each platform (Endless Runner) 0 Answers
How to Instantiate a prefab with radius using OverlapCircleAll ? 0 Answers
Prefabs not instantiating after build 0 Answers
Why do my first 50 instances of a prefab have the same properties? 1 Answer