Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TravisTGMM · Sep 29, 2013 at 10:32 AM · physicslinerendererupdates

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.)

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image $$anonymous$$ · Sep 29, 2013 at 10:51 AM 0
Share

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.

avatar image robertbu · Sep 29, 2013 at 02:51 PM 0
Share

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.

avatar image TravisTGMM · Sep 29, 2013 at 09:44 PM 0
Share

I'll give that a try, and update you guys once I'v dug around with it a bit. Thank you!

avatar image TravisTGMM · Sep 30, 2013 at 03:05 AM 0
Share

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.

avatar image reefwirrax · Sep 30, 2013 at 07:35 AM 0
Share

please mark this question is answered , to take it off the list of unanswered questions

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by TravisTGMM · Oct 02, 2013 at 08:10 PM

I got it working by moving the lineUpdate to a fixedUpdate instead of Update.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges