❔ Im adding a trail to my golf ball. when you drag it. But its not working properly.

it should be in front of the golf ball. like a director. but its not. and its not only in one spot
8 Replies
Jimmacle
Jimmacle17mo ago
$details
MODiX
MODiX17mo ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
Crispy Cable YT
Crispy Cable YTOP17mo ago
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); } not the full code. but the main bits
Crispy Cable YT
Crispy Cable YTOP17mo ago
here
Crispy Cable YT
Crispy Cable YTOP17mo ago
any ideas?
TheBoxyBear
TheBoxyBear17mo ago
$code
MODiX
MODiX17mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat If your code is too long, post it to: https://paste.mod.gg/
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server