- Home /
Question by
ArIaNFury008 · Aug 27, 2020 at 10:59 AM ·
rotationraycastreflection
reflecting rays and rotate this reflecting
Hi , I want make laser with LineRenderer and reflecting some object i want.
and i need rotate gameObject have LineRenderer
i can't understand reflecting in unity very well.
this my code without reflecting :
public Transform Point;
public LineRenderer lineRendere;
public float Speed;
public GameObject EffectDie;
public Animator anim;
void FixedUpdate() {
transform.RotateAround(Point.position, Vector3.back, Speed * Time.deltaTime);
RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.right);
if (hit)
{
Player player = hit.transform.GetComponent<Player>();
if (player != null)
{
anim.SetTrigger("Dead");
Instantiate(EffectDie, player.transform.position, player.transform.rotation);
Destroy(player.gameObject);
}
lineRendere.SetPosition(0, Point.transform.position);
lineRendere.SetPosition(1, hit.point);
}
else
{
lineRendere.SetPosition(0, Point.transform.position);
lineRendere.SetPosition(1, Point.transform.position + Point.transform.right * 500);
}
}
if anyone have suggestion please help thanks .
capture.png
(11.3 kB)
Comment
Your answer
Follow this Question
Related Questions
How does LookRotation work in relation to ray cast? 1 Answer
Raycasting from object rotation? 1 Answer
click to move workig script!! but pls help with rotation!! :( 1 Answer
How do I get an object to rotate around a different axis based on the raycasts hit angle? 0 Answers
Rotate Object relative to a other(I dont get it after 5 days google searching! pls) 2 Answers