Unity 2d raycast


* This is a basic, but powerful barebones 2D platform controller for Unity * It allows you to seperate Walls, Roofs and Platforms, and allows the dropping down through said platforms * It does this using Layers and Raycasts. How to stop falling through floors and colliders in Unity Recently I have been working on a 2D platformer which uses the inbuilt Unity Physics and Rigidbodies. One of the challenges I ran into was that when the player moved above a certain velocity, it would sometimes pass through colliders. static RaycastHit2D Raycast(Vector2 origin, Vector2 direction, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, float minDepth = -Mathf.Infinity, float maxDepth = Mathf.Infinity); With the parameters defined as. origin: The point in 2D space where the ray originates. この記事でのバージョン Unity 5.1.0f3 Personal RayCastシリーズ 1.使い方 2.衝突するオブジェクトの制限 3.Rayを画面に表示 4.2Dで使う はじめに RayCastシリーズ、前回はRayを画面に表示する記事でした。 4回目の今回はRaycastを2Dで使う方法についてです。 It's a pretty common requirement in game development to need to know if a particular character or object is on the ground. For instance, your player may only be able to jump, attack, or interact while they are on the ground. A common way to check this is to use a Raycast, which essentially allows you to detect the d... How to stop falling through floors and colliders in Unity Recently I have been working on a 2D platformer which uses the inbuilt Unity Physics and Rigidbodies. One of the challenges I ran into was that when the player moved above a certain velocity, it would sometimes pass through colliders.