Answer by IvovdMarel
If you want to make it stop when it's close to the target, you can use Vector3.Distance (and check if it's smaller than a certain amount). If you call AddForce every frame, more and more force will be...
View ArticleAnswer by IvovdMarel
I'm assuming the object with the tag "Enemy" have a component EnemyHealth. If that's the case, you want to access that particular enemy and it's component. Rather than calling enemyHealth (which is a...
View ArticleAnswer by IvovdMarel
Old question but I bumped into this and felt the need to answer. Most likely your canvas is set to Pixel Perfect. Disable this and your performance could quadruple (that's what happened to me)
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
To ignore layers you should use layer masks. When you do your raycast, create a layer mask: LayerMask mask = LayerMask.GetMask("YourLayerName"); If you want a more detailed answer I suggest you put...
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 Article