Playback starts YouTube’s embedded player (privacy-enhanced mode).
60 Seconds Tutorial | Grappling hook | Unity 2D
Channel1 Minute UnityDescription from the creator
Link to my game: play.google.com/store/apps/details?id=com.Hoppo…
In this 1 minute tutorial you will learn how to create a grappling, using c# and unity.
Sub to the channel for more usable content that does not waist your precious time.
The code:
public Camera mainCamera;
public LineRenderer _lineRenderer;
public DistanceJoint2D _distanceJoint;
// Start is called before the first frame update
void Start()
{
_distanceJoint.enabled = false;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
Vector2 mousePos = (Vector2)mainCamera.ScreenToWorldPoint(Input.mousePosition);
_lineRenderer.SetPosition(0, mousePos);
_lineRenderer.SetPosition(1, transform.position);
_distanceJoint.connectedAnchor = mousePos;
_distanceJoint.enabled = true;
_lineRenderer.enabled = true;
}
else if (Input.GetKeyUp(KeyCode.Mouse0))
{
_distanceJoint.enabled = false;
_lineRenderer.enabled = false;
}
if (_distanceJoint.enabled)
{
_lineRenderer.SetPosition(1, transform.position);
}
}
In this 1 minute tutorial you will learn how to create a grappling, using c# and unity.
Sub to the channel for more usable content that does not waist your precious time.
The code:
public Camera mainCamera;
public LineRenderer _lineRenderer;
public DistanceJoint2D _distanceJoint;
// Start is called before the first frame update
void Start()
{
_distanceJoint.enabled = false;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
Vector2 mousePos = (Vector2)mainCamera.ScreenToWorldPoint(Input.mousePosition);
_lineRenderer.SetPosition(0, mousePos);
_lineRenderer.SetPosition(1, transform.position);
_distanceJoint.connectedAnchor = mousePos;
_distanceJoint.enabled = true;
_lineRenderer.enabled = true;
}
else if (Input.GetKeyUp(KeyCode.Mouse0))
{
_distanceJoint.enabled = false;
_lineRenderer.enabled = false;
}
if (_distanceJoint.enabled)
{
_lineRenderer.SetPosition(1, transform.position);
}
}
About this tutorial
1 Minute Unity published this 1:38 video tutorial on July 5, 2020. It has been watched 88,202 times on YouTube.
- Channel
- 1 Minute Unity
- Category
- Gaming
- Duration
- 1:38
- Published
- July 5, 2020
- Views
- 88,202
- Likes
- 1,717
Tags
Share
This tutorial in other languages
- FR60 secondes Tutoriel | Grappin | unité 2D
- ES60 segundos Tutorial | Garfio | unidad 2D
- PT60 Segundos Tutorial | Gancho | Unity 2D
- IT60 Seconds Tutorial | Rampino | Unity 2D
- DE60 Sekunden Tutorial | Grappling Hook | Unity 2D
- NL60 Seconds Tutorial | Grappling hook | Unity 2D
- RU60 Seconds Учебное пособие | Крюк | Unity 2D
- PL60 sekund Tutorial | Grappling hook | Unity 2D
- JA60秒チュートリアル|グラップリングフック|ユニティ2D
- AR60 ثانية دروس | تتصارع هوك | الوحدة 2D
- HI60 सेकंड ट्यूटोरियल | हुक जूझ | एकता 2 डी
- ID60 Detik Tutorial | Bergulat kait | Unity 2D