Hey guys! I have been practicing Unity a bit more, as well as following tutorials across both YouTube and the internet in general. I decided to make a game inspired by Flappy Bird; not the most original thing to do now but it is a simple concept and something I can practice making to nurture my skills.
As some of you may know I am not too keen about programming. Most of the code I have used in my project are snippets from other peoples code that they have written. I want to make two obstacles (a pillar from the top and a stack of crates at the bottom) to move towards the player at different heights, but they keep merging into one another despite defining preset locations for them to stay. Here is the code I have as of the moment:
using UnityEngine;
using System.Collections;
public class MovingObstacles : MonoBehaviour
{
//Velocity of the Obstacle
public Vector3 velocity;
//Distance Between Obstacle1 & Obstacle2
public Vector3 distanceBetweenColumns;
void Update()
{
moveObstacle();
}
//Move the obstacle
private void moveObstacle()
{
//The obstacles are going from Right To Left
this.transform.position = this.transform.position + (velocity * Time.deltaTime);
//If the Obstacle reaches the end of the Screen
if (this.transform.position.x <= -13.5f)
{
//if not, increase the distance between Columns when we reach the -13.5 X position
Vector3 TemPosition = this.transform.position + distanceBetweenColumns;
//Change the Y position to a Random One.
TemPosition.y = Random.Range(-5f, 5f);
//And the move the Pipes to that position.
this.transform.position = TemPosition;
}
}
}
I apologise if it sounds like I am asking people to do the coding for me but I am completely stumped! 😮
Additionally I wish to make the background move and repeat so it looks like the player is moving when they are not actually moving; a parallax effect I think? I do not know how to make this happen though.



