Hack Forums
[C#] Space between sprites. [Unity] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Space between sprites. [Unity] (/showthread.php?tid=5219619)



Space between sprites. [Unity] - GewooE - Mar 29, 2016

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=451ADC2A2ED2D0E7!108&authkey=!AAimm1ss1vE_ZfA&v=3⁢hint=photo%2cpng
Wall: https://onedrive.live.com/redir?resid=451ADC2A2ED2D0E7!109&authkey=!AAxqJwKjBiS2n8A&v=3⁢hint=photo%2cpng

I have no idea what can create this space because the this is my first unity game.


* - Ninja - Mar 29, 2016

It appears to be a shadow of the block object that makes it look like its not aligned properly.


* - GewooE - Mar 29, 2016

(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?