Add this simple script to make your 2D games stand out with a nice depth effect! 🎮 Play 7 Awesome Games (Action, Strategy, Management) and Help Support the Channel! ✅ Get the Game Bundle 67% off unitycodemonkey.com/gameBundle.php
@wss_maze.7819 Жыл бұрын
pls help, for me the hills dont snap smoothly in position. They change their position and you can see it very obviusly.
@olddogscanlearnnewtricks60793 жыл бұрын
It is amazing how every single 15-20 minutes video from Code Monkey leads yourself into an hour or even days of deep learning into Unity if you are open to really understand all the aspects of what he is teaching. Excellent content as always !!! Thanks a lot !
@CodeMonkeyUnity3 жыл бұрын
I'm glad the videos helped you! Thanks!
@metalfeng87784 жыл бұрын
You pronunciation is so clear that I watch your videos in 2x speed and I can still comprehend what you're saying. Amazing, thank you for the efficiency boost.
@phantomBlurrrr3 жыл бұрын
Thank you for pointing this out, just saved 8 minutes or whatever
@ToadSprockett5 жыл бұрын
This is so stinking good, it's simple and solid. I've written a couple of these and this is now my go to...
@aldin71585 жыл бұрын
I just hope that one day you won't delete all your videos because they are sooo valuable, I am planning to watch them all from beginning sometime Thank you for this amazing value you are giving us!
@ElSonk5 жыл бұрын
I programmed this myself just recently - but your code is so much better and flexible. Will adapt it tomorrow. Thanks!!
@rishabparmar24974 жыл бұрын
Thanks for this CodeMonkey, really appreciate this. Now, if your parallax is still jittering/ lagging: try one of the following methods, hopefully they might work: - Try alternating between FixedUpdate() and LateUpdate() - Try changing the Interpolation on the player(Interpolate or Extrapolate or None). Try combinations with the above step - Lastly, this worked for me: Try changing the pixel size of the sprites by clicking on the sprite and not the object. Mine was 100, but when I changed it to 64, it ran butter smooth
@Mooskislide4 жыл бұрын
how do I click on the sprite instead of the object?
@ceoofbananaco.9960 Жыл бұрын
OH MY GOD THANK YOU
@rishabparmar2497 Жыл бұрын
@@ceoofbananaco.9960 keep passing the knowledge ahead!
@AsaFalyRayyan Жыл бұрын
you are awesome, this works for player "check point" system
@VoidShadow66 Жыл бұрын
Thanks a lot man i solved all my problems , 4 hours spent on creation big level of my game using a parallax and Cinemachine + drawing my own sprites. Ur vid is great!!!
@ItsAllAboutComedyHere Жыл бұрын
thank you for awesome video , one thing for people who want to use your Script for their project , if you change Scale of your picture ... movement of the picture would not be smooth as the video and thats because texture unit size assume Scale is at one ... so only thing you have to do is to multiply textureUnitSizeX and textureUnitSizeY with transform.localScale.x and transform.localScale.y ... again thank you Code Monkey for amazing videos :) love from an indie dev from IRAN ...
@neonage62945 жыл бұрын
You're always writing such simple stuff in more advanced way, I didn't know when to use mod operator, keep it up! :D
@BRicey4 жыл бұрын
I've tried to write a few of these on my own.... But it was never as simple, robust, and expandable as yours... Thank you so much
@CodeMonkeyUnity4 жыл бұрын
I'm glad you found it useful!
@jean-michel.houbre5 жыл бұрын
Another video really well done and simple to follow. I just love it !
@jdc683 жыл бұрын
Awesome tutorial. Been scratching my head a long time over this, happy to find such an easy solution
@googlefirst4 жыл бұрын
This is by far the best video on Parallaxing.
@MrSixification5 жыл бұрын
Clever. Impressive simplicity. You rock.
@om3rz6625 жыл бұрын
I love you!! Thats exactly what I was searching for!! 😀😂
@hanpolo27277 ай бұрын
Still works 4 years later so thanks bud!
@evoldev54503 жыл бұрын
Can you please tell me what to do if the new position.x of the background does not exactly fit the previous one?
@MioRaem3 жыл бұрын
I did everything till 6:13 and when I test the game, the background layers dont move at all anymore. What the f am I doing wrong? :(
@YannickGames4 жыл бұрын
Super useful tutorial! 👍 Only thing, when I used this with the cinemashine I needed to change the LateUpdate() to fixedUpdate(). Probably because the CM is Updating the camera in fixed Updates 🤔
@bertalannyary37654 жыл бұрын
Hello Code Monkey! Currently I'm making a 2d sidescroller in a pixelart style, and I tried to implement this infinite parallax background. I wrote the exact lines in my script (after failing multiple times I've downloaded the assets, and just copied the script.) but it did not work. Instead of the "background jumping to the other side" mine is kinda following the camera (like I have a wide background object and it keeps stuttering, and it only shows one part). Please, if you could help that would really make my day!
@MrLukimen3 жыл бұрын
Once again, your way is the best! thank's for your content
@d.d.26732 жыл бұрын
It was exactly solution for what i was looking for. Other tutorials can be deleted. Had only problems with layer ordering while using some weird method like puting image on plane object or it wasnt working at all. By the way i like your code style. You do it like normal not amatour.
@juicedup145 жыл бұрын
I was just looking at tuts for this!!
@digen_art Жыл бұрын
I really like the walking animation.
@anirbankarmakar20375 жыл бұрын
It was awesome , keep making such videos. It will be really good if you cover some 3d topic also.
@Plays-wi1yx4 жыл бұрын
I am trying with this code but the background moving with camera but not adjusting with the previous background.
@marcosengelhard54565 жыл бұрын
Hello Code Monkey, is there a reason that you turned start() update() into the private? the variable parallaxEffectMultiplier could be public, if it's public, it would appear in the inspector ( when it's private, you need to write [SerializeField] in order to show on the inspector.)?
@CodeMonkeyUnity5 жыл бұрын
Making a variable public not only exposes it to the editor it also exposes it to the rest of your entire project. So if you have something that is meant to be modified solely in the script and in the editor, make it private and add [SerializeField], that will keep you code nice and clean and make it obvious that no other script will ever touch that field. Start(); and Update(); should always be private, no other script should ever call those.
@bobbycrosby97653 жыл бұрын
Note that if you use scaling this doesn't factor that in. I had to multiply textureUnitSizeX by transform.localScale.x.
@hanmayujiro14333 жыл бұрын
OMG. thanks! =)
@tshubham36 Жыл бұрын
You are awesome. Had to scroll a lot to reach this. But worth it. Thanks!
@hymus8627 Жыл бұрын
Thank you very much
@TheOfficialPolo5 жыл бұрын
Is this the start of Side Scroll game tutorials? God Bless you!
@CodeMonkeyUnity5 жыл бұрын
Yeah that's definitely something I'd like to cover more. I was going to make a complete game like Terraria but had to switch to the Top Down Shooter game because there are still tons of Platformer elements that I haven't covered.
@MinjiKim-k7j2 жыл бұрын
Great video thank you so much!! You saved my day! I assume it doesn't make much difference but substracting the offsetPosition from the transform.position seems more natural for me. Sorry if I got it wrong! I'm just a beginner.
@JanMihail Жыл бұрын
Я тоже заметил это. Я думаю это ошибка и она будет заметна, если размер повторяющейся зоны будет маленький
@MinjiKim-k7j Жыл бұрын
@@JanMihail Why, thank you! I'm happy that someone is on the same page. :)
@Badyliani4 жыл бұрын
Anyone using Cinemachine - change LateUpdate => FixedUpdate. It will stop the jittering.
@lamarhoward84784 жыл бұрын
Amazing, thanks for that! 👍
@BRicey4 жыл бұрын
THIS WAS SUPER HELPFUL
@imheretosleep3 жыл бұрын
I tried implementing this to my game but when I built it to android the background kept blinking, any idea how to fix it?
@IsaacPrice2 жыл бұрын
I wish I could like this video as many times as I can click like for it's duration of the video
@kliment79042 жыл бұрын
Excellent work! Thank you.
@theDarkerSan4 жыл бұрын
A small improvment I found was to change the the lastCameraPosition in the start() from camera position to Vector3.Zero Let's say you build your level with the camera in a certain place, and playtest. looks good. Now if you change the camera position and play again, the parallax start in a place relative to the camera position and this messes things up a little (I found it the hard way). with vector3.zero it will aways have the deffault editor start position.
@nightlifebartenders3 жыл бұрын
THE ULTIMATE GUIDE!
@ThinkCitric4 жыл бұрын
Thanks man! You saved my day! :)
@tigransahakyan28405 жыл бұрын
Great videovand great effect )
@jamiejones87564 жыл бұрын
Working beautiful, thanks!
@thedrewster2437 Жыл бұрын
Ok so everything is working fine other than the clouds are not infinite for some reason and I cannot seem to figure out why. I have toggled off the vertical bool and that's not seeming to help the issue.
@heyyounotyouyou37614 жыл бұрын
I don't know I to thank you You really are smart
@Smarthomeyourself4 жыл бұрын
@Code Monkey: can you check your script with scaled transformation on background graphic? if i scale my graphics up than the background jumps on x-axis if it was moved. I think I have to calculate the texture-width on another way but I didn't understand how. :(
@Howdyhowthis4 жыл бұрын
Didnt know if i'm in time, but if you scale up your sprite simply multiply it with transform.localscale in textureunitsizeX
@Asheroonis2 жыл бұрын
@@Howdyhowthis I know it's been ages since but thank you so much, I've been struggling with this for a while now, you're a life saver!
@Howdyhowthis2 жыл бұрын
@@Asheroonis I was struggling with that for a while too. Glad I'm leaving that comment there. Good luck with your project!
@BaguillaPascual Жыл бұрын
Hi @CodeMonkeyUnity, I am amazed to see that you have still responded to some relatively recent comments and it has given me hope to ask a question. I think I followed the video without errors, but I have a problem with the parallax because when you have to jump seamlessly there is a clear jump. I have been touching the dimensions of my background, I don't know if that could be causing the error. Any help would be appreciated.
@CodeMonkeyUnity Жыл бұрын
It works seamlessly horizontally but not vertically? The issue will be something related to the math and/or the size of the texture. Maybe you're applying the same offset on the X and Y even though it has different width/height? Look at the scene view while playing to see exactly what is going wrong, is it jumping too much or too little? Add some logs to see what values you're working with
@Splash0292 жыл бұрын
Thanks! :D
@Profil25795 жыл бұрын
Very simple and very powerful to use, thanks! =)
@easternunit2009 Жыл бұрын
You must type really fast, based on the very super fast keyboard typing sounds. No, but seriously very good tutorial .
@Kidopya4 жыл бұрын
When i scale sprite game objects in Inspector, parallax lags. how can i scale sprites without lag? I use single sprite mode with full rect and 2000 width for tiling
@toxlandmusic9124 жыл бұрын
Thank god I saw your ad moths ago it was worth it
@hilmanahza26884 жыл бұрын
I was exactly with your code but, instead my player movement scripts didn't work
@VampireForFood4 жыл бұрын
so for whatever reason, the background elements that i add the script to are very shaky and unstable, nothing like the smooth effect you're getting.... any ideas?
@VampireForFood4 жыл бұрын
to add to this, it's only happening in my game window, it looks great in the scene window
@MikhaelHld2 жыл бұрын
Thank you so much! You're amazing!
@an_bean3738 ай бұрын
Hi! I have a random question: when getting the sprite for the game object, why do you call GetComponent().sprite instead of GetComponent() ? To me it sounds like they do the same thing, is there like a small difference between the two? Your videos are incredible, by the way, they are lifesavers!
@CodeMonkeyUnity8 ай бұрын
There is no Sprite component that you attach to a GameObject, just a SpriteRenderer so you cannot do GetComponent(); you need to get the SpriteRenderer and find the sprite attached to it I'm glad my videos have helped you! Thanks!
@Ermite_des_songes4 жыл бұрын
Someone has by any chance a tip that this could work if I change the size of the camera ? My target is that the camera go back more the character run fast. :) It's working by setting the camera on perspective mode but is it good ?
@Pendo82 жыл бұрын
Every so often, the texture jumps and its quite noticable that the image has moved. Has anyone experienced this ?
@SayehAvaPazouki4 жыл бұрын
I just set X Multiplier to 0.9 but its still too fast for me! how can I make it slower?
@david_chan_952 жыл бұрын
Thank you so much! Awesome! 8)
@tangcahill5 жыл бұрын
Hey, Can you think of any reason why this script might not work for me? The general parallax effect works great but after adding the if statement to LateUpdate the images don't align on transition at all. Using a virtual camera rather than a regular camera in my project. If I can't find a solution, would it be acceptable to just have a very long parallax background instead? Cheers.
@IvoryAV4 жыл бұрын
Did you find a solution ? Got the same problem
@theAmbroise163 жыл бұрын
I think that I am facing the same issue. When the background repositions itselfs, there is a small jump. It almost fit perfectly, but we can still notice that it is not aligned. I've copied perfectly and double checked almots everything but it still does it.. If you've found a solution it woud be so much appreciated ! thanks
@jak12329 Жыл бұрын
Did you or anyone figure out why? Got the same issue
@howardxu80502 жыл бұрын
I followed your instructions to create a parallax background, but mine is still showing clear snaps when it triggers. Not useful
@CodeMonkeyUnity2 жыл бұрын
Then you did something wrong, computers are deterministic, if you do exactly what I show in the video you will get exactly the same result.
@khalidalhariri44334 жыл бұрын
What if I want to add stuff to the scrollimg background that appear randomly but gets harder the more the player goes forward?
@thiagobastos1645 жыл бұрын
Great video! I'd like to ask if there's a way to make the background (a static background) always fit the player screen. I've tried many things but it never worked.
@CodeMonkeyUnity5 жыл бұрын
That requires doing some math based on the texture size, sprite pixelsPerUnit and Screen.width and Screen.height
@thiagobastos1645 жыл бұрын
@@CodeMonkeyUnity Does the code that you showed in this video helps with that? If not, do you have one video on the subject? Thanks for the answer!
@ДмитрийНечепуренко-т7д2 жыл бұрын
Why it not works smooth with cinemamachine?
@PhilDeveloper4 жыл бұрын
Why is my background moving backwards on the Z axis :(
@frantaoo28204 жыл бұрын
Finaly something that works for me thank you
@topit4 жыл бұрын
Nice tutorial. But as I am a beginner, I really hope that you will make a tutorial of it using Bolt Visual Scripting. Thank you.
@vergilw70092 жыл бұрын
hello, is it work for the Main camera by orthographic ??
@supercruiser49254 жыл бұрын
I subscribed because you don't shove your face to the camera like other Unity coders.
@dr.gaming20225 жыл бұрын
What about Cinemachine. If I am using Cinemachine will this still work.
@riskybicky83352 жыл бұрын
Hi, the movement of the background goes to move, jitters, and then resets back to its original position? Is this something I can solve? I am using Cinemachine as a camera and the background witth the effect applied is a child of the CM vcam1.Thanks
@CodeMonkeyUnity2 жыл бұрын
It moves then moves back? Sounds like you have some conflicting logic, add some Debug.Log's to see what your code is doing
@RobitI7955 ай бұрын
I made same script like in this video, put same values and setting for sprites, it's noticeable that they're snapping, Is it supposed to be like this or did I do something wrong? I put video in United Programming server
@phantomBlurrrr3 жыл бұрын
I'm having an issue where moving up/down the background does not seamlessly move to where it should be. I double checked the sprite renderer size and it's set properly to the default values when you first drag in the background * 3. Should those default values not be trusted or what.. super inconsistent anyway, sometimes it moves perfectly seamlessly and sometimes not..
@benelliott91583 жыл бұрын
try putting everything in FixedUpdate
@curb474 жыл бұрын
Kinda nice, but can't get it working. When the background layers re-position themselves, they don't align and there is an obvious jump. I've experimented with parameters but no success. In the video, you skim over the section about setting the edge of the texture too quickly, there's no detail. What can I do to fix this? Thanks.
@CodeMonkeyUnity4 жыл бұрын
The texture just needs to repeat itself. The code teleports it into the exact perfect position.
@theAmbroise163 жыл бұрын
@@CodeMonkeyUnity I am facing the same issue. When the background repositions itselfs, there is a small jump. I've copied perfectly and double checked almots everything but it still does it.. Have you found a solution curb47 ? Would be greatly appreciated !
@kristianfejes2133 Жыл бұрын
@@theAmbroise16 did u fixed that? bcs now i am strugglin on it. Please help
@podcastcluster Жыл бұрын
the light mode burns my eyesssss
@CodeMonkeyUnity Жыл бұрын
Sorry but dark mode burns my eyes
@robh55552 жыл бұрын
Where are the best place to get utilities for making games when making and selling games?
@jul78713 жыл бұрын
my background sprite turns into just 1 plain color when i change the draw mode to tiled. it looks normal in the other 2 modes, but tiled mode doesnt work. its just a rectangle.
@olddogscanlearnnewtricks60793 жыл бұрын
click on your asset and change the import setting: Mesh Type from Tight to Full Rect.
@resistancefighter8882 жыл бұрын
Hey, thank you so much for the video! Can you please explain why you're adding offsetPositionX to the new background position and why did you calculate it in the way you did?
@CodeMonkeyUnity2 жыл бұрын
It needs to be perfectly calculated so that when it snaps to a different position the effect is invisible, if you don't calculate it perfectly then you will see the background "move" instead of flawlessly repeating
@resistancefighter8882 жыл бұрын
@@CodeMonkeyUnity Thanks for the explanation, I understand that this is meant to make the snapping invisible to the user, my question is why does this achieve this?
@JanMihail Жыл бұрын
@@resistancefighter888 Вообще более правильно сделать camera.position.x - offsetPositionX. В данном случае это может быть несущественным, т.к. если изображение достаточного высокого разрешения, то склейка со смещением в пару пикселей не будет заметна, но это может стать заметным на более мелком разрешении. Достигается это за счёт того, что offsetPositionX вычисляется таким образом, что он всегда кратен ширине повторяющейся части фона и сдвигается ровно на то расстояние, на котором идёт повтор. Таким образом мы за один кадр перемещаем повторяющуюся зону вперед или назад и оно идеально стыкуется и кажется, что картинка не двигалась.
@telocim2 жыл бұрын
Would you consider updating this or giving some additional instructions on getting it to work with Unity 2022? I've tried several times, even re-installed Unity 2019. I haven't been able to get it to run as displayed in the video. The biggest issue is the player is "invisible" but the background is moving around nicely. After playing around with the shader settings (I'm a novice) I was able to see a blocky white player-like object moving around the screen. Please and thank you!
@CodeMonkeyUnity2 жыл бұрын
There's nothing here that is dependent on a specific Unity version. Sound like you just have an issue with your sorting layers, not shaders unitycodemonkey.com/video.php?v=5_BwFB-1dAo
@IlieStoianLiveShowАй бұрын
How can I make this effect if my character doesn't move, but only jumps, like the flappy bird?
@CodeMonkeyUnityАй бұрын
It's the exact same thing, you just have different layers moving at different speeds, doesn't matter if they're moving in the X or Y axis
@IlieStoianLiveShowАй бұрын
I made it 🥰🥰
@haithammahmoud68255 жыл бұрын
how do u manage enemy damage per levels do u use formal? because if player bought weapon and armor will kill enemy easy so game will be boring i don't want to make game very hard or very easy can u help with that Thanks
@Tidalley Жыл бұрын
How do you apply this to TileMaps?
@lighthousestudio152 жыл бұрын
Guys what to do when the mountains snap? It snaps whenever I move pls help
@alexv96074 жыл бұрын
the script is not working for me i get an error i says: transform.position assign attempt for 'clouds_4' is not valid. Input position is { NaN, -4.730000, 0.000000 }. UnityEngine.Transform:set_position(Vector3) ParallaxBackground:LateUpdate() (at Assets/Scripts/ParallaxBackground.cs:31) how to fix this? i dont know how but great vids.
@naughtychrome13223 жыл бұрын
I know it's a year later but I copied everything you did on the video fine and it worked but when I made a new project and I did everything again. everytime I moved horizontally or vertically it's snaps the background so I can see in game that It is definitely moving and it doesn't look smooth any suggestions?
@kojimamcmaple3 жыл бұрын
I think LateUpdate() is the issue. I had to change everything to Update() for it to work.
@rayztech73842 жыл бұрын
thanks for the tutorial. i followed everything and i keep getting "object reference not set to an instance of an object" and the error comes from vector 3 line 24 in your code
@CodeMonkeyUnity2 жыл бұрын
Use Debug.Log to find what is null unitycodemonkey.com/video.php?v=5irv30-bTJw
@nateham42602 жыл бұрын
I know it's a long shot because of the age of the video, but with the [SerializedField] I am getting an error in unity that says "the type or namespace name "SerializedField" could not be found" am I doing anything incorrect?
@CodeMonkeyUnity2 жыл бұрын
It's SerializeField
@wadetwynham4734 Жыл бұрын
In the beginning of the script when you add camera.main.transform it doesn't reference the camera/ highlight it. So when I go out of the script it gives error 'Camera does not contain a definition for Transform.......etc Can anybody please assist? Just a note I had to wipe my pc and downloaded the new version of unity and c#
@CodeMonkeyUnity Жыл бұрын
Make sure you write the code correctly, it's Camera.main.transform not Camera.main.Transform, code is case sensitive
@itayefraim35593 жыл бұрын
if your parallax is still lagging, Maybe it's because you scale the picture up
@nischalbhatta8155 жыл бұрын
You inspire me!
@CodeMonkeyUnity5 жыл бұрын
Glad to hear it!
@iyanez3 жыл бұрын
forsome reason the background goes backwards not forward
@curb474 жыл бұрын
I had a 2.5D game, with3D characters, platforms and objects etc on Z=0. Imagine Little Big Planet. I need to set up an infinite scrolling background like this, but it only seems to work when the sprites are on Z=0, which obviously intersect with my game objects. Is this technique strictly ONLY for completely flat 2D sprite based games? Thanks.
@CodeMonkeyUnity4 жыл бұрын
If your camera is 3D then you don't need this since you have Parallax by default, just place your backgrounds at different Z positions. The further an object is from the camera the slower it will appear to move.
@curb474 жыл бұрын
@@CodeMonkeyUnity Yes, I understand that, but to get the kind of of parallax you demonstrate in your tutorial, the horizon layer will have to be really far away on the Z, and a huge image. Is there not a performance hit if images are hugs, or scaled up? Thanks.
@alanwest6814 жыл бұрын
I could get it working on my own dodgy project, but when I import the provided package file, all the textures and scripts are broken/missing. I'm using Unity 2019.3.15f1. Any suggestions?
@CodeMonkeyUnity4 жыл бұрын
What exactly is broken or missing?
@mr.fakeman47184 жыл бұрын
For me, the code shown in the video doesn't work for creating the vertical infinite. However, it does work for the X axis, and I also can move for the Y axis, except that for the Y axis, it is not infinite... too bad. Here is my code: using UnityEngine; using System.Collections; using System.Collections.Generic; public class ParallaxBackground : MonoBehaviour { [SerializeField] private Vector2 parallaxEffectMultiplier; private Transform cameraTransform; private Vector3 lastCameraPosition; private float textureUnitSizeX; private float textureUnitSizeY; private void Start() { cameraTransform = Camera.main.transform; lastCameraPosition = cameraTransform.position; Sprite sprite = GetComponent().sprite; Texture2D texture = sprite.texture; textureUnitSizeX = texture.width / sprite.pixelsPerUnit; textureUnitSizeX = texture.height / sprite.pixelsPerUnit; } private void FixedUpdate() { Vector3 deltaMovement = cameraTransform.position - lastCameraPosition; transform.position += new Vector3(deltaMovement.x * parallaxEffectMultiplier.x, deltaMovement.y * parallaxEffectMultiplier.y); lastCameraPosition = cameraTransform.position; if (Mathf.Abs(cameraTransform.position.x - transform.position.x) >= textureUnitSizeX) { float offsetPositionX = (cameraTransform.position.x - transform.position.x) % textureUnitSizeX; transform.position = new Vector3(cameraTransform.position.x + offsetPositionX, transform.position.y); } /* if (Mathf.Abs(cameraTransform.position.y - transform.position.y) >= textureUnitSizeY) { float offsetPositionY = (cameraTransform.position.y - transform.position.y) % textureUnitSizeY; transform.position = new Vector3(transform.position.x, cameraTransform.position.y + offsetPositionY); }*/ } }
Hi nice tutorial, but in android, it causes slow... When I remove it, it's fast... Is there any workaround for that? thanks... (I am using cinemachine2d by the way)
@avery67874 жыл бұрын
Hi pantoy, did you find any workaround for this? I am having the exact same problem
@archer86294 жыл бұрын
when you code... you don´t speed up the video do you..?
@steffstar3 жыл бұрын
Hi! How do you make the backgrounds move accordingly in scene view when you move the camera around? I got the parallax effect to work when I run the game, but when I move the camera in scene view, it doesn't show the effect. Thank you!
@CodeMonkeyUnity3 жыл бұрын
The script only runs when the scene is playing. If you want it to run while not running you need some sort of Editor script kzbin.info/www/bejne/mH7YhaZ3osZnqs0
@hhashh23274 жыл бұрын
How can I make it work in an endless runner?
@KalponicGames4 жыл бұрын
Hi I think you can make an array for background elements. Then we can add as many background assets we want.
@ricks80115 жыл бұрын
I'm noticing a lot of stuttering as you move. Is there a way to smooth that out? Thanks!
@CodeMonkeyUnity5 жыл бұрын
I don't see any stuttering, are you talking about the video or in-game?
@aava53124 жыл бұрын
@@CodeMonkeyUnity I'm getting stuttering as well in my project. The faster my character moves the worse the stutter seems but its always stuttering, I have pixel art not sure if that could be the root of the issue.
@aava53124 жыл бұрын
@@CodeMonkeyUnity Fixed it by doing this if (cameraTransform.position.x - transform.position.x >= textureUnitSizeX) { transform.position += new Vector3(textureUnitSizeX, 0, 0); } else if (cameraTransform.position.x - transform.position.x = textureUnitSizeX) { float offsetPosition = (cameraTransform.position.x - transform.position.x) % textureUnitSizeX; transform.position = new Vector3(cameraTransform.position.x + offsetPosition, transform.position.y, transform.position.z); }
@janmiodekrulez44724 жыл бұрын
@@aava5312 It's incorrect logic because "cameraTransform.position.x - transform.position.x >= textureUnitSizeX" probably will never execute exact when cameraTransform.position.x - transform.position.x IS EQUAL your textureUniteSizeX. That's why you need offset. 👍
@alistairshanks81412 жыл бұрын
i also got jittering and this fixed it for me, thanks very much. do you know why the jittering occurs?
@GamerXPlayz5 жыл бұрын
Amen video on how to add level system on unity
@CodeMonkeyUnity5 жыл бұрын
Here's a Level System kzbin.info/www/bejne/oXymfYCsqMx0iJI
@GamerXPlayz5 жыл бұрын
@@CodeMonkeyUnity no-no not character level I said game level