- Home /
Lasersight flickering
Good day! I'm working on a Weapon system, which consists of 4 scripts, which can create almost any conventional weapon (melee or ranged - will be available at the Asset Store). Right now I'm working on Laser Sight part: an option to create a GameObject (here: a test sphere, representing the laser pointer), which is always kept at the RaycastHit.point position in front of the weapon. Easy-peasy.
The problem is - any update of it's position creates very ugly stuttering of the laser pointer. Here's the code in Update Function:
if(UseProjectedCrosshair)
{
var CrossHit : RaycastHit;
if(Physics.Raycast(CrosshairOrigin.position, CrosshairOrigin.forward, CrossHit, ProjectionRange, CrossHitAgainst))
{
if(CrossHit != null)
{
ProjectedCrosshair.gameObject.SetActive(true);
ProjectedCrosshair.transform.position = CrossHit.point - (CrosshairOrigin.forward * CrosshairPull);
ProjectedCrosshair.transform.LookAt(CrosshairOrigin.transform);
}
if(CrossHit == null)
{
ProjectedCrosshair.gameObject.SetActive(false);
}
}
}
(CrosshairPull pulls it up a bit so it won't clip through walls).
Ideas?
PS: Additional and optional question: is there a way to contact the author of this here popular and awesome script: http://wiki.unity3d.com/index.php?title=DontGoThroughThings about it's licence and commercial permisions? It's not a must right now, just asking by the way. ;)
Your answer
Follow this Question
Related Questions
3D Space Shooter Firing Projectiles 0 Answers
RaycastHit not sending message 2 Answers
If collider between two points get this point 1 Answer
How do i scale a prefab laser to hit.distance 1 Answer
Creating a Ray Gun 1 Answer