- Home /
Drag line between game objects
I'm trying to make a game where you drag lines to connect objects of different colors but cant make the lines cross eachother. I have a particle system designed for the line. So my idea is to have the particle system be disabled until the player touches it, then you drag and the particle system would change it's length to have one end where the players finger/mouse is. I would want the x axis to change length to match the mouse position and to rotate instead of acting as a trail...
I'm sorry if this is a basic question, I'm new to C#.
To further this question, I think I know a way I could do this using a game object that is always underneath the mouse, i have looked at many codes and tried them all and none of them make the game object move, if you could tell me how to do this also that would be great.
A line Renderer would be far easier to use, as you can just set the start and end points.
Anyway, for a ParticleSsystem, you would have to find the halfway point between the start point and the current end point (where the cursor is). Here is an answer that will help you with this. Then you would have to somehow calculate the size of the ParticleSystem so it reaches both points exactly. This depends on how big the PS and it's particle is initially. To rotate the PS so it's x axis (left axis) points towards the end or start point, you may be able to use Transform.LookAt and make it look at a point that is perpendicular to the directional vector between start and end point.
Thank you, and the problem with line render is that its not animated, It's too blank... so if there is a way to apply an animation to it that would be amazing.
Your answer
![](https://koobas.hobune.stream/wayback/20220612051040im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Visual Studio 2010 causing: Inconsistent Line Endings... 3 Answers
How to increase max particles in a particle system against a timer? 0 Answers
How to change the sprite in "texture sheet animation" from three different sprites? 1 Answer