So I have this basic script: when you click a button you get 1 cash. But I wanted to make a combo mechanism where you get 2 cash for 1 click when two images are alligned. Anyone who could help me?,
The most basic way to do it is checking wether those images are aligned or not before adding the cash.
Also depends on what you mean by aligned (on the same place? one on top of the other? one on the left or right of the other?) I am going to assume it is “on the same place or close enough”.
First, you need to get a reference to said images to access and check their properties. The most basic way of achieving this is to create properties in your class that will show in the inspector, then assign them in the inspector. Since the “Transform” component of an image has the center position we can use that. If those images are in the UI, “RectTransform” would be a better option because it has more information (you can use the top of the images, or the corners, etc).
Fortunately, there is no need for us to calculate the magnitude (distance in every axis combined), as the Vector3 class has a property we can use: distance.magnitude, and compare it with a threshold (i am using “1”, this is a long distance in the 3D world but in the UI could be very small depending on how it is rendered)