i’m a scholar in austria. I’m engaged on a challenge for varsity, the place we’ve to make our personal first recreation with unity. As a result of it’s the first time utilizing unity, i continuously run towards issues. Most of them, i mounted already. However this downside bought me caught for a couple of days now. I’m very sorry, that i used that many photos. Possibly within the image there may be some data i didn’t provide you with. The identify of the collision map is “FirstLayer_Col”
That is what i’ve bought up to now. My map is fairly huge. I used the tile palette, to color them in. I additionally used various kinds of layers. The bottom layer is generally gras or water. On prime of that, i put the timber on, that are seen within the subsequent image. I created a brand new tilemap to make it a collision tilemap. I took a random tile and put it on every part i wish to have a collision on.
I modified to order of layer to 10 for the collision tilemap, so i may see the place i’ve to place the tile to cease the participant from, so he cant stroll over or by it. After i put the tile on my wished location, i modified the order of layer again to 0 so i couldnt see it anymore. I dont know if that may be a downside or not. I’ve not discovered some other resolution that labored for me. The collision tilemap has a tilemap collider and the participant named “South_0” ,due to the sprite i used for it, has a field collider and a rigidbody. Each collider is a 2D one.

After i begin the applying with the collision layer on 10. I can undergo it, stand on the place, the place the collision needs to be as there isn’t any collision. When i alter the order of layer to 0, so it isn’t seen, i can stroll to the tree, however then my recreation begins to shake and the participant rotates. Then there may be some sort of collision, however when i attempt to undergo it, my recreation begins to shake very sturdy after which my participant can stand in the midst of the tree as there is no collision. It appears to be like very “buggy” and the participant rotates in any course. I can’t work out, how i could make the collision to cease the participant from coming into the sector of my tilemap collision with out making the participant go loopy and make the entire display screen shake. I simply need the participant to cease in entrance of it, in order that there isn’t any approach of bugging by it. I hope i defined my downside so you may perceive it. Possibly it’s only a small, little repair, however i couldn’t discover any resolution. The final image is how my participant takes care of i ran up towards the tree with the collision map on layer 0. The participant mustn’t rotate and simply go, up, down, left, proper.

My Code for my Participant:
utilizing UnityEngine;
utilizing System.Collections;
public class PlayerMovement : MonoBehaviour {
Route currentDir;
Vector2 enter;
bool isMoving = false;
Vector3 startPos;
Vector3 endPos;
public float t;
public Sprite northSprite;
public Sprite eastSprite;
public Sprite southSprite;
public Sprite westSprite;
public float walkSpeed = 0.5f;
public bool isAllowedToMove = true;
void Begin()
{
isAllowedToMove = true;
}
void Replace () {
if(!isMoving && isAllowedToMove)
{
enter = new Vector2(Enter.GetAxis("Horizontal"), Enter.GetAxis("Vertical"));
if (Mathf.Abs(enter.x) > Mathf.Abs(enter.y))
enter.y = 0;
else
enter.x = 0;
if(enter != Vector2.zero)
{
if(enter.x < 0)
{
currentDir = Route.West;
}
if(enter.x > 0)
{
currentDir = Route.East;
}
if(enter.y < 0)
{
currentDir = Route.South;
}
if (enter.y > 0)
{
currentDir = Route.North;
}
swap(currentDir)
{
case Route.North:
gameObject.GetComponent<SpriteRenderer>().sprite = northSprite;
break;
case Route.East:
gameObject.GetComponent<SpriteRenderer>().sprite = eastSprite;
break;
case Route.South:
gameObject.GetComponent<SpriteRenderer>().sprite = southSprite;
break;
case Route.West:
gameObject.GetComponent<SpriteRenderer>().sprite = westSprite;
break;
}
StartCoroutine(Transfer(rework));
}
}
}
public IEnumerator Transfer(Remodel entity)
{
isMoving = true;
startPos = entity.place;
t = 0f;
endPos = new Vector3(startPos.x + System.Math.Signal(enter.x), startPos.y + System.Math.Signal(enter.y), startPos.z);
whereas (t < walkSpeed)
{
t += Time.deltaTime * walkSpeed * walkSpeed;
entity.place = Vector3.Lerp(startPos, endPos, t);
yield return null;
};
isMoving = false;
yield return 0;
}
}
enum Route
{
North,
East,
South,
West
}
```




