How can I create a walking zone logic for my player?

First I will show a screenshot and explain the logic I think of and what I’m trying to do :


The small circle is the Player.

The black rectangle is the target the player is walking towards.

The green zone is where the player slow down. Once entering the green zone and facing the target by calculating the distance from the target the player start slowing down until stop.

When the player just rotating facing the opposite direction away from the target in this point something show switch the speed logic if the player was slow down to stop if the player is facing the opposite direction he can start walking again and the speed should be increasing slowly to the normal speed the same idea when slowing down to stop so speed up to normal.

Now if the player is leaving the green zone once left the green zone using a flag or some helper and reset everything so if the player will enter the green zone again facing the target he will slow down to stop again.

  • When the player is getting some distance from the target and facing the target slow down to stop.

  • When the player stopped and then if the player rotating facing the opposite direction let the player the option to move again with increasing the speed back to normal.

  • When the player is moving away from the target some distance for example out the green zone reset everything and if the player will face the target again and enter the green zone as distance from target slow down to stop again.

This script is attached to some object and make the logic I wanted :

using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine;  public class FireEffect : MonoBehaviour {     public GameObject player;     public GameObject longDistanceDescriptionTextImage;     public TextMeshProUGUI text;      private Animator playerAnimator;     private float timeElapsed = 0;     private float lerpDuration = 3;     private float startValue = 1;     private float endValue = 0;     private float valueToLerp = 0;     private float angle;      // Start is called before the first frame update     void Start()     {         angle = transform.eulerAngles.y;         playerAnimator = player.GetComponent<Animator>();     }      // Update is called once per frame     void Update()     {         var distance = Vector3.Distance(player.transform.position, transform.position);          Vector3 dir = (transform.position - player.transform.position).normalized;         float dot = Vector3.Dot(dir, player.transform.forward);          angle = transform.eulerAngles.y;         if (distance < 10 && dot > 0.9f)         {             if (timeElapsed < lerpDuration)             {                 valueToLerp = Mathf.Lerp(startValue, endValue, timeElapsed / lerpDuration);                 playerAnimator.SetFloat("Forward", valueToLerp);                 timeElapsed += Time.deltaTime;             }             playerAnimator.SetFloat("Forward", valueToLerp);             longDistanceDescriptionTextImage.SetActive(true);             text.text = "It's too hot , I can't continue.";         }         else         {             if (dot < -0.9f)             {                 if (timeElapsed > lerpDuration)                 {                     valueToLerp = Mathf.Lerp(endValue, startValue, timeElapsed / lerpDuration);                     playerAnimator.SetFloat("Forward", valueToLerp);                     timeElapsed += Time.deltaTime;                 }                 playerAnimator.SetFloat("Forward", valueToLerp);             }         }     } } 

I’m not sure if this is the right way to make the script but it does working for the slow down to stop part :

if (distance < 10 && dot > 0.9f)         {             if (timeElapsed < lerpDuration)             {                 valueToLerp = Mathf.Lerp(startValue, endValue, timeElapsed / lerpDuration);                 playerAnimator.SetFloat("Forward", valueToLerp);                 timeElapsed += Time.deltaTime;             }             playerAnimator.SetFloat("Forward", valueToLerp);             longDistanceDescriptionTextImage.SetActive(true);             text.text = "It's too hot , I can't continue.";         } 

but it’s not working in the else part the speed is not increasing slowly back to normal but increasing at once to normal. The lerp is not working for the increasing back.

another problem is when the player in the else part facing away from the target if I will rotate the player with the keys and move him again to the target he will walk regular nonstop to the target without slow down again.

I’m not sure what logic should be here for 100% but I think if the player is facing away from the target start increasing to normal speed and if in the middle I rotate the player facing the target again because I’m inside the green zone then slow down to stop the player maybe a bit faster to keep the same 10 distance like in the script from the target. Don’t let the player to pass over the 10 distance from the target when facing the target.

Can a creature with a natural walking speed of 0 ft. get up from being prone?

In a one-shot I recently played the players were fighting a homebrewed Weeping Angel (stats). It has a walking speed of 0 ft. and can teleport 80 ft. on its turn under some conditions. One of the players knocked the Weeping Angel, which is essentially a statue, over by using the shove action. On its turn, the Weeping Angel was prone with a speed of 0 ft. It then used its Impossible movement to teleport away and appear upright again.

Now there are three options on how to rule this situation:

  1. The Weeping Angel uses half of 0 ft., so still 0 ft., to get up from being prone and proceeds as normal
  2. The Weeping Angel lifts the prone condition simply by teleporting
  3. The Weeping Angel is prone, and can’t get up anymore

According to the rules, which of this rulings (if any) would be correct?

Unity Animation Controller and walking diagonally keeps switching between the two diagonals?

Using Unity 2019.4.1f1 Personal.

Unity Animation Controller nodes

I have the above Animation Controller. When only walking in one direction at a time and when you stop you stay facing that direction, this works as planned.

Successfully walking pokemon trainer

All of the transitions do not have an exit time and have a fixed duration of 0. I don’t know what info to give as this is the first time I’ve used animation. Let me know and I’ll add relevant details.

Here’s my update function that updates the variables in the animator:

void Update() {   float h = Input.GetAxisRaw("Horizontal");   float v = Input.GetAxisRaw("Vertical");    animator.SetFloat("Horizontal", h);   animator.SetFloat("Vertical", v);    if (Mathf.Abs(v) < Mathf.Abs(h)) {     // flips the renderer to reuse other handed image     spriteRenderer.flipX = h > 0;   }    // no actual movement until I figure this out } 

What I’m experiencing that I want to fix is when running diagonally:

Broken diagonal movement

It seems that when walking diagonally then the animator variables for Horizontal and Vertical are both either 1 or -1 and this causes the alternating of the sprites. What I’d like to happen is that the state machine would deterministically pick either N/S sprites or E/W sprites when moving diagonally. Turning on "Can Transition To Self" seems to properly pick a direction and stick to it but it fails to animate when only moving in a single direction. It looks like it’s constantly transitioning to itself which starts over the cycle so I’ve left that unchecked on all transitions.

I’m not sure what the best way to fix this is. Most attempts I’ve tried so far complicate the state machine to the point it’s unmaintainable. I also couldn’t find anything about introducing priorities in a way that fixed the jitter.

What’s the idiomatic Unity way to achieve clean diagonal movement in 2D?

Walking Image

Why are you selling this site? No time to manage

How is it monetized? Not planned yet

Does this site come with any social media accounts? No

How much time does this site take to run? Its all running on wordpress

What challenges are there with running this site? No Challenge.

3D Collisions – Walking below a slope pushes me through the floor

Here’s a really short video (less than 30s) of this issue :

When I move the player towards a slope (the player is below it), it pushes the player inside the floor Collider instead of blocking it.

I’ve searched the Internet for a while but haven’t found anything about it

Do you have something in mind ?
Thanks for your time

Info : I move the player using rigidbody.MovePosition()

The collision of the player is a Capsule.

Differences Between “Walking Arsenal (Gear)” and “Walking Arsenal (Inventor)”?

So, I’ve been trying to make a technical character; a super-inventor if you will. And I can’t seem to understand what the benefit of either Ability is.

If you have Walking Arsenal, linked to either Gear or Inventor, what would the difference be? Is there any benefit or detriment of either?

Walking a graph without recursion

I’m working on a class that receives a relational EDM/data model (e.g. a SQL DB or OData API manifest) and performs a couple tasks on them (not necessarily at the same time, could be two separate runs). The class/alg doesn’t know anything when it starts, finds everything from the schema data, but the schema doc is static so could be re-processed. What I call “sets” are tables, REST API endpoints, etc., i.e. publicly/user-accessible entry points to the data. One of the things I output is a “path” to each type (e.g. A is a set, so just “A”; B is not a set but is a child of A, so “A→B”). Another is whether anything changes between two models (true/false equality of the model pair).

Unfortunately, the input isn’t necessarily “correct”–some related child types are not available on their own (only through parents), some are missing relations (no ID fields) so I infer based on existence of the property, some have relation loops (A → B → C → A). Some have child collections (1:N) with no mapping type, so I infer that based on the relation prop and invent a mapping type.

Anywho, my current solution uses depth-first and recursion and keeps track of the types it has seen to prevent overflow and false negatives. We’ve found some wacky corner cases (in addition to the above; such as a type set existing, but the type definition itself isn’t in the schema). What I have written works, for what we’ve tested/seen so far, but I am curious if there are other methods by which this sort of traversal or processing might be done, hopefully that could be implemented more simply than what I have now, which gets increasingly ugly and seems more fragile as more weird cases come up.

Generally, what I do now, single-threaded, is: get the list of sets, find outliers that don’t exist in the opposing model, then for each set common between the two models get the type of that set, call CompareType(t1, t2). This will compare properties on those types between the two models and then descend into each related type. If a child has been seen before or is itself a set, I assume it’s OK (skip/return true) because it gets checked on its own.

This is in C# though I’m not sure that is very important as far as the general design of the algorithm. I was curious if there is a better way to do it, e.g. some sort of token walking like I’ve seen in JSON parsers, or a FSM-like solution, or something like that.