Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Space between sprites. [Unity]

So I made a simple 2D setting where you can move a block.
But I can not completely snap to another sprite (wall).

Screenshot:
Spoiler (Click to View)

Inspector settings wall:
Spoiler (Click to View)

Inspector settings player:
Spoiler (Click to View)

PlayerMovement Script:

Code
using UnityEngine;
    using System.Collections;
    
    public class PlayerMovement : MonoBehaviour {
    
        public KeyCode moveUp;
        public KeyCode moveDown;
        public KeyCode moveLeft;
        public KeyCode moveRight;
    
        public float speed = 10f;
    
        // Use this for initialization
        void Start () {
        
        }
        
        // Update is called once per frame
        void FixedUpdate () {
    
            Vector2 v = rigidbody2D.velocity;
    
            if (Input.GetKey (moveUp)) {
                v.y = speed;
                v.x = 0;
                rigidbody2D.velocity = v;
            } else if (Input.GetKey (moveDown)) {
                v.y = speed * -1;
                v.x = 0;
                rigidbody2D.velocity = v;
            } else if (Input.GetKey (moveRight)) {
                v.x = speed;
                v.y = 0;
                rigidbody2D.velocity = v;
            } else if (Input.GetKey (moveLeft)) {
                v.x = speed * -1;
                v.y = 0;
                rigidbody2D.velocity = v;
            }
            else
            {
                v.x = 0;
                v.y = 0;
                rigidbody2D.velocity = v;
            }
        }
    }

These are the files I'm using:
Player: https://onedrive.live.com/redir?resid=45...hoto%2cpng
Wall: https://onedrive.live.com/redir?resid=45...hoto%2cpng

I have no idea what can create this space because the this is my first unity game.
It appears to be a shadow of the block object that makes it look like its not aligned properly.
(Mar 29, 2016 09:33 AM)Ninja Wrote:  It appears to be a shadow of the block object that makes it look like its not aligned properly.

Thanks a lot for your answer I was really frustrated and I hope this helps can you maybe tell me where I can disable the shadows in unity?


Bump, I am really frustrated can someone please help me?


Possibly Related Threads...
Thread / Author Replies Views Last Post
by HackersFeb 5, 2025 09:07 AM 0 77 Feb 5, 2025 09:07 AM
Last Post: Hackers
[Shell] by ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™Jun 6, 2020 07:15 PM 6 347 Jun 6, 2020 07:15 PM
Last Post: Sajuuk
[Python] by DistrictMay 17, 2019 08:05 PM 5 151 May 17, 2019 08:05 PM
Last Post: demarco