I'm trying to use a line renderer to act like a grappling cable for a vehicle of mine in my game. It seems, however, from the camera view the line is only visible up to a certain distance far away. Is there anything I can do to make the camera see more of the line?
EDIT: I should clarify, I know how to extend the length of the line, I have that script written. What I'm saying is that the line is hard to see from the camera when looking from behind. I want to give the player a good idea of how far the hook is going, even when it's over 30 units away on the forward z axis?
FURTHER:
When I turn my car to the side while moving with the line extended a distance, I can see much more of the line since I start to see the line from the side???
line renderer is a line between two points.
you just need to adjust the values under 'Positions'.
you can also click on the three dot icon at the top to 'edit points in scene view' and drag the further point outward, you can also add points with the plus icon beside it.
you could also use raycast for your grappling hook
I'm not super experienced with unity's linerenderer. However it looks like the linerenderer stops at your pink light barrier. I'm not sure if the linerenderer works like a raycast however.
EDIT:
Ok. Now I get what you want to achive. My guess is that unity does not render the line because it becomes smaller than a pixel and the lineRenderer is not a 3D element. I had some succes by using a different curve. Try to increase the width of the line the further away it is.
Related
I am working in Unity2D and have a character who can shoot in all directions. The game has mobile controls and the player will choose his shooting direction with a joystick on the right side.After testing I found it rather difficult to correctly determin where the shot is going to land at. To convey this to the player I wanted to add a sort of "shooting line of sight" to the player. It is moving around the player according to the joysticks position. (As seen in the picture)
Because I want the line to be pixelated (to match the design theme of the game) I cant use the standard LineRenderer component as it doesn't support such pixelated lines. So I started looking for solutions to this problem and stumbled upon Bresenham's line algorithm. After implementing it into the game I knew which x, y coordinates I had to fill with a pixel. Currently every single white pixel in this line is a GameObject with its own SpriteRenderer and a single white pixel as a sprite. In my test scenario up to 400 pixels where rendered at once. I am already using an object pooling system to minimize the performance drag. Moving this line around drops me from around 1100 Fps down to like 200 Fps in the editor. I know it will be slightly better in the build game but I am sure it will take a toll on older mobile devices when enemys, animations etc. are present in the level.
So my question is: Is there a better or more efficient way to render the sprites? Or (preferably) do you have a better idea on how to render this line at all without creating ~300+ GameObjects. (e.g. Shaders (Zero experience), drawing on a texture)
I am grateful for any ideas that lead me into the right direction.
I would like to achieve something like this:
I've already done something similar using the Unity particle system. It works fine but the problem is when you rotate the pointer, a wave is formed. Is there any other way?
If you want to avoid the wave using particle effects, you will need to move each particle immediately by how much it needs to move to get into its new position. The reason you get a wave now is because you're only changing the emitter's direction.
Instead, it might be a better approach to use a wrapped LineRenderer and scrolling the UVs on the texture/renderer on each Update using lineRenderer.material.SetTextureOffset. You'll also need to calculate the points to draw the line, and set those as appropriate in Update as well.
This way, when you change the aim, the LineRenderer's positions can all move accordingly and the dots will always appear to be in a series of straight lines.
Increase the speed of the Simulation Speed in the main (top) section of the Particle Settings. Try 10, to start with. You might need even higher. Default is 1.
I have the following problem:
Imagine playing a 2D jump 'n' run game in a 3D world. You can only go left- and right. But the path you walk isnt a straight line. There are curves. So looking at this image:
It may be a bit clearer what I want. Simply by clicking the "right" key, my Sphere should move along the black line.
How do I accomplish this?
How do I move the sphere (I am guessing a simple .AddForce) and...
How do I make it go along the black line.
Remember that the sphere should be still able to jump. So there is no restriction in the Y-Axis.
How can I override the physical marker in unity to just make the physical marker invisible in camera while detecting any object.
Like in this video:
https://m.youtube.com/watch?v=R_F1LvK5gCk
And many other videos.
This maybe isn't the correct answer but, I'll put my ideas here because sadly it doesn't fit in the comment section.
I just watch the video and some of the reels they show as his works.
First, yes, in deed they make the marker a sort of invisible marker, but if you look closely, like a 0.25 speed and pushing space bar very fast to look it in slowmo, you can see a kind of "artifact" in between the girl's fingers that makes me think there's no invisible marker but a texture that are covering the marker. Maybe a cylinder that gets his texture from the video camera input.
Now, how I do that?
There are several ways to get the pixels from the webcamera, even Unity has one function. The trouble is, I dont want all the pixels but a little tiny part of the camera render, specifically the one's around my marker.
In my experience, and in his examples, they are using OpenCV, another unity plugin, so they can track anything, from faces, hands, or markers, so I can't be quite sure they are using Vuforia alone or in combination.
My idea is, with OpenCV you can catch your marker and his contour, then ask for the pixels outside the contour of your marker, those pixels will be the skin tone of the person and latter apply them as a texture over some plane or 3d model that can cover your marker. You can have the pixels at right side and left side of the marker and use a average function betwen them so it could look nice or if you like the adventures you can try to use some kind of digital images processing method to get bether results.
I'm not sure if you can have the pixels arround a marker just using just Vuforia. Honestly I've never try it before.
Well, that's my idea.
If you can get it better I'll like to hear about it.
I am making a game in which you shoot a ball. I want there to be a line that follows your finger when you touch the screen (showing you the path the ball will travel). It needs to be straight, and also a little side question:
Once the line is drawn, is there a way to detect if it collides with a sprite? So, if the line hits a wall, it won't go through it? Any help is appreciated, Thanks!
for drawing only a line you can use ccDrawLine function and you can change line color using glcolor4f you can also change line width using glLineWidth but iprefer to use these functions for debug purpose. it's better if you try some sprites drawing for accual game.
for collision testing I suggest you use box2D and create body(and fixture) for both line and moving sprites. you can edit fixtures you created when ball changes position.