- Home /
A method to update a Vertex draw every step.
I'v been scouring forums and post for about a week now, and after making some good progress I hit a brick wall. I have an object that is moving at a set speed with a projectile weapon mounted to it. Recently, I have added a lineRenderer that will show me where a shot is likely to land based on the angle and velocity of my shots. (Which is determined by where I'm touching my screen).
Sounds all good right? Here's where the problem arises.
The line renderer shows accurately, but only if my object is not moving. The moment I add some motion to it, the line renderer stays in place until I re-touch the screen. (Imagine if you were lobbing a grenade in Gears of war, but the projection lines origin point stayed in place instead of moving with your character.)
I'v been scratching my head for a while on how to make that line re-render per step, If it is possible, and if not what alternative should I be exploring?
Side notes: The formula I'm currently using increments my starting position by the velocity and gravity each step. Ideally, I want it to re-do this method each step to keep a nice consistent prediction going.
Any help is appreciated, and I apologize if I missed something on here already, however I have been searching for a while :P. (Also, it's almost 6 am, and my mental integrity has crumbled.)
How do you calculate the origin of the line render? As for what it sound like the line render only spawn at the moment you shoot your projectile, and not having more instructions on where the origin is going the line just stays there until next shot.
You probably need to update the origin position every frame on Update or maybe with a coroutine.
As @$$anonymous$$ indicates, you need to update the positions in the line renderer each time you move your object. If the gun angle and the force don't change, then you can just add the delta moved to each position used by the line renderer. If the angle or force changes, you will have do your physics calculation each frame.
I'll give that a try, and update you guys once I'v dug around with it a bit. Thank you!
I'd like to thank everyone for the suggestions. I fixed the issue by moving the call to my prediction line into LateUpdate, and forcing it to redraw each step so long as its selected.
Funny thing is, I fixed it by mistake while addressing something else XD.
please mark this question is answered , to take it off the list of unanswered questions
Answer by TravisTGMM · Oct 02, 2013 at 08:10 PM
I got it working by moving the lineUpdate to a fixedUpdate instead of Update.
Your answer

Follow this Question
Related Questions
How can i create a character like dragon hill game, Digging underground, what collider should i use? 0 Answers
change boxcollider2D length during runtime 0 Answers
Bouncing Raycast "Laser" Not Working? 1 Answer
How to configure a rope like joint 0 Answers
Predicting ball direction on collision 0 Answers