- Home /
Grenade throw with indicator
Hey fellow develpoers...I have a question!
I have a throw script and i would like to make a throw indicator (like a parabola or smthing) to show where the item will be thrown so it can be more accurate...
However i dont know how to achieve it! :/
Can someone help ?
This is the script
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RootMotion.Dynamics {
public class ThrowIt : MonoBehaviour
{
public PuppetMaster puppetMaster;
public PropRoot propRoot;
internal void OnMuscleRemoved()
{
throw new NotImplementedException();
}
public float thrust;
public Animator anim;
void Start()
{
puppetMaster.OnMuscleRemoved += OnMuscleRemoved;
}
void Update()
{
if (propRoot.currentProp != null && Input.GetMouseButton(1))
{
anim.SetBool("IsAiming", true);
if (Input.GetMouseButton(1) && Input.GetMouseButtonDown(0))
{
anim.SetTrigger("Throw");
}
// Do not add force here, the muscle will not be removed before the next FixedUpdate.
}
else
anim.SetBool("IsAiming", false);
}
public void Throw()
{ propRoot.currentProp = null; }
private void OnMuscleRemoved(Muscle muscle)
{
muscle.rigidbody.AddForce(Camera.main.transform.forward * thrust + Vector3.up * 20, ForceMode.Impulse);
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612235903im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
AddForce and AddRelativeForce not forcing in the right directions 2 Answers
Freeze Position + collision? 0 Answers
When Movement speed Change once it never change again 1 Answer
Why object goes sometimes through walls by adding force ? 2 Answers
What is the best way to move the player with physics without using MovePosition? 0 Answers