I created a new game type for my block breaker where there is a second paddle at the top, but the idea is that is moves inverted compared to your paddle to make this particular game mode difficult. However, despite my initial thoughts, attempting to get this to work is not very easy.
I could’ve simply made it a double-paddle, but I wanted to be a bit more daring and now I’m back on the forums asking for help as no one appears to have found a solution for this very problem.
I copy and pasted part of the code from the other paddle, thinking I’d just need to find an easy way to tinker with the x position, but I’ve yet to find a way that makes it work and not shoving it into either the right or left collider.
Code:
using UnityEngine;
public class ReversePaddle : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
MoveWithMouse();
}
void MoveWithMouse()
{
Vector3 paddlePos = new Vector3(0.5f, transform.position.y, 0f);
float mousePosInBlocks = Input.mousePosition.x/ Screen.width * 16;
paddlePos.x = Mathf.Clamp(mousePosInBlocks, 0.5f, 15.5f);
transform.position = paddlePos;
}
}
update:
Thought I would give everyone a picture as to what exactly I’m trying to accomplish with this. The first picture below is what I get when I load the game up and want to remain the same. Both paddles in the centre, facing each-other.
When I move to one side, I want the second paddle at the top to move in an opposite direction so it’s inverted to where my mouse moves as demonstraited below in a terrible editing job in Pain shows you, maybe moving it further so it avoids the score like shown below.
I’ve tried to look up many ways how to do this and a common suggestion seems to be you have to find out what the location for the centre is. I hope someone is able to come up with a solution for this problem I’m having with what to code and how to code it.