playMaker

Author Topic: Line Renderer Glitch  (Read 2332 times)

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Line Renderer Glitch
« on: February 06, 2017, 01:31:36 PM »
Hello guys,

it took me some time to make a functioning line renderer continuous laser beam in a 2D sidescrolling game, but there it is. Unfortunately, a glitch occurs.

Here's how it's setup:



First step is getting the original line renderer X position for later reference.



Standby state, waiting for player to fire the laser beam.



Raycasting with line cast. Hit location is stored to be used for positioning end object for line renderer. Bool test is used to determine if object is hit or not.



Nothing hit, line renders from ship to original end point, everything fine.



We hit something! Magic happens, hit location is converted from vector2 to vector3, line renderer end point is set to hit location, line is drawn, then to loop gets back to raycasting again.

Everything works fine, but two bad things happen.

As you can see, the first thing is that the laser sometimes gets through the object.



Second thing is this:



I separated line casting and the draw line events in different states so the line wouldn't be drawn until the hit position is taken and line renderer end object set on hit position, but it occurs if the first shot did not hit anything. Do you think that i should perhaps put setting the position of line renderer end object in a separate state before firing or maybe use a raycast? Set Position in a different state would cause one frame of lag tho.

Please help, i'm going out of my mind >:(
Available for Playmaker work

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Line Renderer Glitch
« Reply #1 on: February 08, 2017, 03:08:07 AM »
I tried putting the set position of a line renderer end object in a separate state, between Raycast and Deal Damage states, but it's not good, it gets messed up.

I'm out of ideas  :P
Available for Playmaker work

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Line Renderer Glitch
« Reply #2 on: February 09, 2017, 01:45:13 AM »
Hi,

 You should add visual tags on your gameObjects defining the end of the trail and check in the scene view where that object is, it seems that it could simply be at the same position as the start resulting in a trail of lenght 0.

 Bye,

 Jean

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Line Renderer Glitch
« Reply #3 on: February 09, 2017, 02:13:05 AM »
Hello Jean,

i checked, that doesn't seem to be the issue. I know it looks like it when i get close in the first gif, but line length is not 0. Also, that is DEFINITELY not the problem in the second gif, but i will see frame by frame where is the end object positioning.
Available for Playmaker work