Answer by IvovdMarel
You should use hit.point ( the point where it hit), not hit.distance (the distance from your object to the object that was hit). In addition, you should check the 'Use World Space' checkbox.
View ArticleAnswer by IvovdMarel
If your level names are the same as the text in the input-field, it's as simple as: string levelName = inputField.text; SceneManager.LoadScene(levelName); Of course don't forget to add using...
View ArticleAnswer by IvovdMarel
Replace the OnTriggerStay method with: void OnTriggerEnter2D(Collider2D coll){ if (gameObject.tag == "squarerow"){ triggered = true; } } void OnTriggerExit2D(Collider2D coll){ if (gameObject.tag ==...
View ArticleAnswer by IvovdMarel
Rather than continuously checking wether or not you are touching the object, you should set a boolean to true, similar to this: if (Input.GetMouseButtonDown(0)) { if(Physics.Raycast(ray,...
View ArticleAnswer by IvovdMarel
You can in the update multiply the alpha of the particle effects by your totalAlpha property which starts at 1 and slowly goes down to 0.
View ArticleAnswer by IvovdMarel
uGUI works with a 'parent controls child' attitude, not the other way around. Therefore, the thing that you want (child controls parent) is a bit of extra work. First, add a VerticalLayoutGroup or...
View ArticleAnswer by IvovdMarel
Ways to move your buttons: - Mecanim. Unity allows you to use their mecanim animation system for your UI. - Code. You can use a method such as Vector3.Lerp to gradually move your object from point A to...
View ArticleAnswer by IvovdMarel
Had the same issue, restarting Unity seems to fix it for a while but it keeps on coming back... wtf?
View ArticleAnswer by IvovdMarel
Hi John, I recommend using a tween engine such as DOTween (my favourite and it's free!) or iTween. Very easy to customize and tweak through code or the inspector.
View ArticleAnswer by IvovdMarel
Besides the methods of a list starting with uppercase (Add, Remove) I see nothing wrong with this code. It should work. However, this might be a better approach: To get the surrounding objects of any...
View ArticleAnswer by IvovdMarel
Although I agree it has been answered many times - it's not always correct, so please find the correct approach here: if (GetComponent().GetCurrentAnimatorStateInfo(0).IsName(“Attack")){ print("Playing...
View ArticleAnswer by IvovdMarel
Although I am not sure if this answers your question, but if your crabs are using the same animator, but different animations, I recommend creating two crab prefabs (one for each animation setup),...
View ArticleAnswer by IvovdMarel
The public float speed is defaulted to 0, but can be set in the Unity inspector. Note: changing the value in code won't do anything, make sure you change it in the inspector!
View ArticleAnswer by IvovdMarel
I recommend not using a for-loop, but instead use InvokeRepeating. Example: int nCardsToPush = 5; void Start () { InvokeRepeating("PopCard", 0, 0.5f); } void PopCard () { if (nCardsToPush > 0) {...
View ArticleAnswer by IvovdMarel
The 'Trigger' refers to a parameter that you have create in your animator. Go to Window > Animator In the top left corner you will see both 'Layers' and 'Parameters' Click Parameters Click on the...
View ArticleAnswer by IvovdMarel
Using Dictionaries to read out JSON objects is very common but it's much easier to serialize it to a struct or class (which is also built-in to Unity using JsonUtilty.FromJson and JsonUtility.ToJson)....
View ArticleAnswer by IvovdMarel
'Highlighting' is a pretty vague term, but if you'd like to instantiate something like a particle system where you clicked (or a light, anything really) you'll need to use Raycast. RaycastHit hit; if...
View ArticleAnswer by IvovdMarel
Yes, it is possible to do bone animation and position / scale tweens through the Unity Animation window. However, compared to Flash, this is definitely quite limited. There are a few plugins that make...
View Article