I have a script that is trying to make to things appear as smashing together, I have done it by haveing smasherBottom.Transform.Translate (Vector2.up * SmashSpeed) for the bottom part, as expected it moves up.
Then for the top arm, I thought just doing the same but making the number of SmashSpeed negative. smasherTop.Transform.translate(Vector2.Up * -SmashSpeed) but the problem is, the top the smasherTop does the same movement as smasherBottom.
using UnityEngine;
using System.Collections;
public class SmasherScript : MonoBehaviour {
public GameObject smasherBottom;
public GameObject smasherTop;
public bool isUp = false;
public int SmashSpeed;
void OnMouseDown(){
Debug.Log ("MouseDown detected");
if (isUp == false) {
smasherBottom.transform.Translate (Vector2.up * SmashSpeed);
smasherTop.transform.Translate (Vector2.up * -SmashSpeed);
isUp = true;
}
}
void OnMouseUp(){
Debug.Log ("MouseUp detected");
if (isUp == true) {
smasherBottom.transform.Translate (Vector2.up * -SmashSpeed);
smasherTop.transform.Translate (Vector2.up * SmashSpeed);
isUp = false;;
}
}
}