I have tried everything but what works please help
what I want it to do is add 1 to the currentcloud int when i click the gun see image it reads equal to the main cam x and y
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rightgun : MonoBehaviour {
// sprite for Rightgun
public Sprite Rgun;
// render for Right gun
private Collider2D Rgcollider; // 2d collder for the Right gun
private SpriteRenderer Rgunrender;
private Color Rgold = new Color(207F, 181F, 59F, 0.5F);
// Use this for initialization
void Start () {
Rgunrender = gameObject.GetComponent<SpriteRenderer>();
Rgcollider = gameObject.GetComponent<CapsuleCollider2D>(); // sets your 2d collder equal to an compent? maybe
}
// Update is called once per frame
void Update () {
//Makes a gameobject equal to the thoughtbubble object
GameObject DialogRgun = GameObject.Find("Thoughtbubbles");
Rgunrender.sprite = Rgun;
Actionbubbles ClassRgun = DialogRgun.GetComponent<Actionbubbles>();
// makes a class to access for my data check on current cloud ex dialogRgun.current cloud
if (ClassRgun.Currentcloud <= ClassRgun.Numberofclouds) {
GetComponent<SpriteRenderer> ().color = Rgold;
if (isRgtouched ()) {
// do stuff
ClassRgun.Currentcloud = ClassRgun.Currentcloud + 1;
}
} else {
GetComponent<SpriteRenderer>().color = Color.red;
}
}
public bool isRgtouched() {
bool result = false;
Vector3 wp = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector2 mousePos = new Vector2(wp.x, wp.y);
wp.z = 20.192019463f;
Debug.Log (mousePos);
if (Input.GetMouseButtonUp(0))
{
if (Rgcollider == Physics2D.OverlapPoint(mousePos)) {
result = true;
}
}
return result;
}
}