Crispy Cable YT
Crispy Cable YT
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Im adding a trail to my golf ball. when you drag it. But its not working properly.
any ideas?
10 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Im adding a trail to my golf ball. when you drag it. But its not working properly.
here
10 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Im adding a trail to my golf ball. when you drag it. But its not working properly.
not the full code. but the main bits
10 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Im adding a trail to my golf ball. when you drag it. But its not working properly.
private bool isDragging; private bool inHole; private void Update() { PlayerInput(); } private bool IsReady() { return rb.velocity.magnitude <= 0.2f; } private void PlayerInput (){ if (!IsReady()) return; Vector2 inputPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); float distance = Vector2.Distance(transform.position, inputPos); if (Input.GetMouseButtonDown(0) && distance <= 0.5f) DragStart(); if (Input.GetMouseButton(0) && isDragging) DragChange(inputPos); if (Input.GetMouseButtonUp(0) && isDragging) DragRelease(inputPos); } private void DragStart() { isDragging = true; lr.positionCount = 2; } private void DragChange(Vector2 inputPos) { Vector2 dir = (Vector2)transform.position, pos; lr.SetPosition(0, transform.position); lr.SetPosition(1, (Vector2)transform.position + Vector2.ClampMagnitude((dir * power) / 2, maxPower / 2)); } private void DragRelease(Vector2 pos) { float distance = Vector2.Distance((Vector2)transform.position, pos); isDragging = false; lr.positionCount = 0; if (distance < 1f) { return; } Vector2 dir = (Vector2)transform.position - pos; rb.velocity = Vector2.ClampMagnitude(dir * power, maxPower); }
10 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Can someone please help me with a unity error code. Ill send part of the script.
thank you
16 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Can someone please help me with a unity error code. Ill send part of the script.
ill try it again now
16 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Can someone please help me with a unity error code. Ill send part of the script.
ive tried that
16 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Can someone please help me with a unity error code. Ill send part of the script.
26 to 29
16 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Can someone please help me with a unity error code. Ill send part of the script.
private void Awake() { if (onEnemyDestroy != null) { onEnemyDestroy.AddListener(EnemyDestroyed); }
16 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Can someone please help me with a unity error code. Ill send part of the script.
Error Code
16 replies
CC#
Created by Crispy Cable YT on 7/10/2023 in #help
❔ Can someone please help me with a unity error code. Ill send part of the script.
NullReferenceException: Object reference not set to an instance of an object EnemySpawner.Awake () (at Assets/EnemySpawner.cs:27)
16 replies