Endless Runner Level Generator in Unity Tutorial (Spawn Level Parts FOREVER)

  Рет қаралды 189,422

Code Monkey

Code Monkey

5 жыл бұрын

🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
Let's create a Level Generator to make levels for a Infinite Endless Runner in Unity 2D.
✅ Get the Project files and Utilities at unitycodemonkey.com/video.php...
Endless Runner Level Generator (Difficulty + Highscores) in Unity • Endless Runner Level G...
Simple Jump in Unity 2D
• Simple Jump in Unity 2...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
📍 Support on Patreon / unitycodemonkey
🤖 Join the Community Discord / discord
📦 Grab the Game Bundle at unitycodemonkey.com/gameBundl...
📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
#unitytutorial #unity3d #unity2d
--------------------------------------------------------------------
Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.
I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
- Website: unitycodemonkey.com/
- Twitter: / unitycodemonkey
- Facebook: / unitycodemonkey

Пікірлер: 768
@CodeMonkeyUnity
@CodeMonkeyUnity 5 жыл бұрын
Check the follow up video where we complete our Endless Runner Mini-Game with increasing difficulty and a Highscore Table kzbin.info/www/bejne/naSnhHiLhLF6fqc
@sagarrawal5195
@sagarrawal5195 4 жыл бұрын
can anyone please tell me how to make and image as an platform for the player to run im very beginner i only want make an 2d endless runner or a runner game with levels but there are good tutorial out there
@gamedevspecialist220
@gamedevspecialist220 4 жыл бұрын
How can I delete the prefabs after it left the screen?
@shikkuu8295
@shikkuu8295 3 жыл бұрын
@@gamedevspecialist220 acually im new to unity but you could say destroy after secodnds or you could make a border which is folloing the player and destroyes the platforms then the player also haves a time limitation i dont know if i could help
@shikkuu8295
@shikkuu8295 3 жыл бұрын
@@sagarrawal5195 you know now? i made it over a tilemap but you can also just use sprites
@MrBucket77
@MrBucket77 Жыл бұрын
How can I make it not infinite but that there is an end?
@JamesArndt
@JamesArndt 4 жыл бұрын
Couple of concerns I would have addressed for beginners. You'd require a way to remove the old tiles after they've left the screen, otherwise this system continues to build up resources over time that would eventually lead to memory errors. Second, this system does not implement a way to reset the player to the world center, so as the player continuously moves away from the origin precision will be lost. After enough time playing the app will either crash or the player will become unstable due to floating point imprecision. I would have addressed these two issues first and foremost for any infinite scrolling system as they are core to the system itself not causing application crashes.
@VoidFriend
@VoidFriend 3 жыл бұрын
Thanks u dude, appreciated.
@icedwarm69
@icedwarm69 3 жыл бұрын
Yes. Just do a triggered collider that destroys a object if hit
@nz9531
@nz9531 3 жыл бұрын
OnBecameInvisible works for this
@COLDoCLINCHER37
@COLDoCLINCHER37 3 жыл бұрын
Can you explain the origin thing? Okay what if your,re player dosent actually move it just seems like it's moving...
@breno8119
@breno8119 3 жыл бұрын
@@COLDoCLINCHER37 He is talking about a re root system I believe: kzbin.info/www/bejne/d6LId6Z6g710arc
@illia_mikhow
@illia_mikhow 4 жыл бұрын
Very simple and fluent guide, thank you! Also, if anyone want to optimize application, you can simply add to LevelPart prefabs simple self destroy script: private float secondsToDestroy = 20f; void Start() { StartCoroutine(DestroySelf()); } IEnumerator DestroySelf() { yield return new WaitForSeconds(secondsToDestroy); Destroy(gameObject); } Have a nice day :)
@bruhvioli
@bruhvioli 4 жыл бұрын
Great idea! What if i wanted to destroy the level parts with the click of a button?
@illia_mikhow
@illia_mikhow 4 жыл бұрын
Watch a video "how to handle button on click event on Unity" If you want to destroy all level parts on scene, I would do it like this: Put a tag on each of levelparts, and made a ClickDestroy script, which firstly saves references to all Level Part gameObjects: var parts = Gameobject.GetComponentsByTag("Levelpart"); And than using foreach loop - delete all objects foreach(var obj in parts) Destroy(obj); And than you should put this in separate function in script, and link it to button on click event. Maybe I am wrong in some places, because I dont have opened Unity in front of me, and I wrote functions from head. Good Luck!
@bruhvioli
@bruhvioli 4 жыл бұрын
@@illia_mikhow i did it like this: public void DestroyLevelParts(){ levelParts = GameObject.FindGameObjectsWithTag("levelPart"); for(var i = 0 ; i < levelParts.Length ; i ++) { Destroy(levelParts[i]); } } but when restarting the game you have to place the lastEndPosition back to the fiorst level part like this: lastEndPosition = startPosition.transform.position;
@MrSmoofist
@MrSmoofist 3 жыл бұрын
Thanks! just one thing it destroys the parts before you reach them lol, i did it like this: for (int i = 0; i < levelParts.Count; i++) { Destroy(levelParts[i]); } edit: sorry for missing some extra- i made a new gameobject list to contain all the level part clones, then destroy only the clones in the list
@romeo4333
@romeo4333 3 жыл бұрын
@@MrSmoofist i get the error: The name 'levelParts' does not exist in the current context' im a unity noob so this is probably easy to fix but an answer would be nice :)
@rafbanaan
@rafbanaan 5 жыл бұрын
Awesome! I had some ideas in the past, but I never got around on how to start one of these.
@trevorjkeegan
@trevorjkeegan 3 жыл бұрын
Awesome tutorial. Trying to go from a brackeys beginners tutorial into unity intermediate 3D endless runner was a bit difficult but I think I can apply this concept in 3 dimensions space.
@Salmontres
@Salmontres Жыл бұрын
Thank you for another great video! I can't count the number of times I go off to make a new mechanic, and you happen to have the perfect video for it!
@matthewspencer6669
@matthewspencer6669 5 жыл бұрын
Great tutorial. I'd really love some more ECS tutorials, specifically showcasing more complex areas like instantiating complex hierarchy objects from jobs and setting data on the child nodes. Maybe some unity physics stuff too.
@seattlebellevue3355
@seattlebellevue3355 4 жыл бұрын
One of the best tutorials. Taught with such simplicity. Pls make more such tutorials. Thanks.
@bramvanwambeke1859
@bramvanwambeke1859 5 жыл бұрын
Great video, I've been trying to get a random level generator working, you really helped me alot thanks.
@CodeMonkeyUnity
@CodeMonkeyUnity 5 жыл бұрын
Create a Infinite Endless Runner Level using Prefabs to make it very easy to create multiple level parts that get randomly chosen. It would be very simple to take this and create separate lists containing some Easy Level Parts and some Hard ones and just change which list it grabs from the further the Player gets. The Project Files also work as a great starting point if you're interested in making a Endless Runner.
@incpwnge
@incpwnge 5 жыл бұрын
Hi. Thanks for such ez for all tutorial =) Is this script applicable for 3D model? The model will run on 2D endless runner. For those who see a part of the player, like a fist, helmet, simply do this; (faced this problem on previous projects) Open the file V_Animation.cs and in the Init() function add these two lines right after "isInit = true;" System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); This totally fixes.
@sagarrawal5195
@sagarrawal5195 4 жыл бұрын
can anyone please tell me how to make and image as an platform for the player to run im very beginner i only want make an 2d endless runner or a runner game with levels but there are good tutorial out there
@user-gs4bv4qj4z
@user-gs4bv4qj4z 4 жыл бұрын
If it would be realy endless moving player and not world around player, can couse any trouble when player will approach any high numbers at X? Can you show some mechanics of world moving or give some tip, for seamless reseting player "at zero"? thx in advance
@Hisnameisluca
@Hisnameisluca 2 ай бұрын
you have to add a colider so you can stand on it and depending if you are making a 2D or 3D game you will need a diffrent collider you can find them under component hope it helped@@sagarrawal5195
@CasperA
@CasperA 5 жыл бұрын
Please do more randomly generated stuff!
@hlimajunior
@hlimajunior 3 жыл бұрын
Amazing, man! That´s this I´ve been looking for! Thanxs!
@mono-pg9wm
@mono-pg9wm 4 жыл бұрын
It was very helpful. Thank you!
@louislemur
@louislemur 4 жыл бұрын
Tutorial really helped thanks a lot!
@zsirothehero4330
@zsirothehero4330 4 жыл бұрын
Nicely done!
@RobertBojor
@RobertBojor 5 жыл бұрын
Haha, if this isn't the internet guessing what I'm working on, I don't know what it is. I was tinkering on a pixel art mini-game and wanted to generate the levels randomly :) Keep up the good work!
@martimking1craft
@martimking1craft 5 жыл бұрын
google is watching you I was thinking that everyone already knew
@NawabKhan-vq5de
@NawabKhan-vq5de 5 жыл бұрын
it was amazing keep it forward sir please
@NotTolik708
@NotTolik708 2 жыл бұрын
thank you so much helped me a lot for my three dimensional project
@vijayanand2783
@vijayanand2783 2 жыл бұрын
Nice Tutorial
@baroianandrei7883
@baroianandrei7883 4 жыл бұрын
Thanks you so much, it gave my game a purpose
@shubhameditz1683
@shubhameditz1683 2 жыл бұрын
Really Helped Me
@OmeedNOuhadi
@OmeedNOuhadi 2 жыл бұрын
Awesome tutorial!!!
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Thanks!
@KuariThunderclaw
@KuariThunderclaw 4 жыл бұрын
Great video and definitely appears to have some relevance beyond endless levels but a question comes to mind as I look this over. Don't you eventually get an overflow of resources if for whatever reason a player manages to go on long enough? Say there was a reason one needed to optimize things? I'm assuming you'd just destroy all the level objects that the player is past at the same time as loading the new ones in?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yup exactly, if you were to implement this in a complete game you would definitely clean up the old platforms. Just cycle through the list and do a simple distance check, if too far, destroy it
@faraday3833
@faraday3833 4 жыл бұрын
great tut!
@alexkhazov7264
@alexkhazov7264 4 жыл бұрын
Great video and technique! I do see one possible way to make it even better, and that's by adding a cleanup for the parts that are far behind the player, otherwise, after playing for a while, unity would have to process hundreds or even thousands of objects) Would be interesting to see this same mechanic done in ECS!
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Yup the clean up would indeed be a necessary addition in order to use this in a proper game
@siddisking
@siddisking 4 жыл бұрын
I was thinking the same thing and wondering if the creator would mention this... B/w how would one do the cleanup for the platforms and objects which are no longer in the camera view?
@alexkhazov7264
@alexkhazov7264 4 жыл бұрын
@@siddisking The simplest solution would be to use the OnBecameInvisible callback, and destroy the gameobject - docs.unity3d.com/ScriptReference/MonoBehaviour.OnBecameInvisible.html Note the small comment they put at the end - this callback also happens when the scene view camera stops seeing the object. So, when the editor scene view camera cannot see the object, it will be destroyed. I would probably only include this function in a built version using #if !UNITY_EDITOR #if !UNITY_EDITOR private void OnBecameInvisible() { Destroy(gameObject); } #endif
@lingais
@lingais 3 жыл бұрын
for those who had problems with Player and GetPosition as i did (for hours, because im new), here's hw i fixed it, hope it helps! For player error, create a script called Player with this code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { public Vector3 GetPosition() { return transform.position; } } attach that script to the player. For GetPosition error, add this code to your LevelGenerator script from the video: public Vector3 GetPosition() { return transform.position; } Many thanks to Jaristos Smith from deep in this video comments and Code Monkey for simplifying the solution for a newbie in one of the comments!
@krisery8907
@krisery8907 3 жыл бұрын
I solved it like this: First I changed the SerializeField to a GameObject and not Player: [SerializeField] private GameObject player; And after that just simply use the transform.position function: if(Vector3.Distance(player.transform.position, lastEndPosition) < PLAYER_DISTANCE_SPAWN_LEVEL_PART) ...
@GrimmjowJxMimiru
@GrimmjowJxMimiru 3 жыл бұрын
@@krisery8907 Thanks man that works! One more question for you and anyone else. I get my platforms spawn just as i set the initial ones like 3 or 5. But when my character comes to the end of the last platform which was spawn at the start of the game, no new one is spawned. It seems there is an error with the update function to check for the position or for the new spawning. Hope someone has an info for it.
@krisery8907
@krisery8907 3 жыл бұрын
​@@GrimmjowJxMimiru Check if the Platform spawns in the SceneView when you run the game. If yes then make sure that all platforms that spawns are set to 0 in the z Position.
@GrimmjowJxMimiru
@GrimmjowJxMimiru 3 жыл бұрын
@@krisery8907 In the Scene View there is also nothing generated. I just cant find the issue. But thanks for the reply, i will need to further check this.
@christinerichard4198
@christinerichard4198 3 жыл бұрын
Please guys help me support this new Endless Runner, im sure you'll love it and it'll really help the devs out play.google.com/store/apps/details?id=com.ObinnaStudios.TheCollectors
@FreedivingTrainer
@FreedivingTrainer 4 жыл бұрын
Thanks for video. What about clear memory by removing parts which user run from?
@butcherbio
@butcherbio 2 жыл бұрын
I'm new to unity and was wondering if it is possible to do the same kind of generation, but with a tile map? Because I'm kinda in the void right now.
@PixelGeekMaster
@PixelGeekMaster 4 жыл бұрын
Thanks ! ! ;)
@raptorswire7212
@raptorswire7212 2 жыл бұрын
great beginner tutorial, however you should at least mention which parts are actually inefficient to use and how to optimize them (object pooling, object.Find killing performance etc...)
@ahmedthebest
@ahmedthebest 5 жыл бұрын
Can you expand this system more, It still need some tweaks like You should get rid of spowne level parts Can you show us How to use This system To generate A top down Road For example
@at930pmgames
@at930pmgames 3 жыл бұрын
And if the player dies or want to play again, it will respawn different level parts so every time someone plays, it will be a different map? Whats the best way to build a platform game considering optimization?
@s1m1ng7on
@s1m1ng7on Жыл бұрын
Great tutorial as always! Wondering how I could do the same but with a group of tiles instead
@CSteph_
@CSteph_ 8 ай бұрын
How?
@RhodeynRusty
@RhodeynRusty 6 ай бұрын
Make sure the parent object your Level Part belongs to has a Grid component on it! Otherwise you'll only save one single tile to the prefab.
@josedeolio8464
@josedeolio8464 4 жыл бұрын
Nice Tutorials really helps, I have question I have added all the elements and characters and all the scripts needed. I added the background last but now it seems to be covering everything I did. I did it as a new Gameobject and added everything there it has it's own parallax script attached. any way I can get it behind the character? Thanks!!!
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
If you're working in 2D check the SpriteRenderer Sorting Order and Sorting Layer
@boomboom3794
@boomboom3794 4 жыл бұрын
Videos look really interesting, is there a way to see all of these tutorials in one playlist, from beginning to end?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
For this one I just did one more with increasing Difficulty and Highscores kzbin.info/www/bejne/naSnhHiLhLF6fqc And I have done other videos on Simple Jump and Ground Check
@fheus2439
@fheus2439 4 жыл бұрын
I have a problem: when i want to generate my Level, either I can make an infinite backgrond, which i saw in another tutorial OR i make the camera stick onto my character. Is there a way to have a looping Background Image AND a to-the-character-sticking camera?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
You just need to apply the same logic used to spawn platforms to spawn the background. As the player moves a lot in one direction, spawn another tile of the background.
@fheus2439
@fheus2439 4 жыл бұрын
@@CodeMonkeyUnity okay, that worked.Thank you very much!
@knowledgeseeker8735
@knowledgeseeker8735 27 күн бұрын
If you're having a problem with making the origin of the levelpart different from the child of it then add a new object and remove the sprite renderer (after giving it a random image) then move your real part and adjust the invisible part to make the levelpart origin different.
@TheBrickBuilderYT
@TheBrickBuilderYT Жыл бұрын
Hey anyone and Code Monkey i have the problem, that the my LevelPart_1 generates mostly in but also under the start platform. This happend when i set the Endposition to the end of the object. if i put the endposition object in the air it generates fine.
@8978martin
@8978martin 5 жыл бұрын
I love this channel you can teach us in this type of game to make an ia that will escape from us and that the coins will give us more speed to be able to catch the ia you could use the spiderman who is trying to catch a thief obstacles make us lose speed and if the thief reaches a goal before we catch him we lose
@qtheking5915
@qtheking5915 4 жыл бұрын
AI?
@meistergong8759
@meistergong8759 4 жыл бұрын
[serializefield] private Player player; doesn't work. Can you help me pls? Error: The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?)
@kairodger238
@kairodger238 3 жыл бұрын
I have the same problem
@peterwettenburn3397
@peterwettenburn3397 3 жыл бұрын
I have the same problem too!
@jonuko9678
@jonuko9678 3 жыл бұрын
I have it too
@nhlanganisotshabangu3774
@nhlanganisotshabangu3774 3 жыл бұрын
@@jonuko9678 If you still need help w this, replace Player w the name of your player movement script
@nhlanganisotshabangu3774
@nhlanganisotshabangu3774 3 жыл бұрын
If you still need help w this, replace Player w the name of your player movement script
@mariorolli4309
@mariorolli4309 3 жыл бұрын
I have the problem, that the Endless Runner isn't Endless. For one reason, I don't know why, the minium-distance between the Player and the Last EndPosition grows. And at one Point the Spawn function stops to Spawn new Platforms. Can anyone help?
@Charlie-ei4wh
@Charlie-ei4wh 4 жыл бұрын
it says that there is an error when i type in the direction for the obstacles to spawn?
@oystudios3052
@oystudios3052 4 жыл бұрын
Hello, I have a question, I followed to 8:25 but when i tried the code you typed before that it gave an error: NullReferenceException: Object reference is not set to an instance of an object I am brand new to unity in fact this is the first thing i am making and wanted to have this in the game but i know nothing of c# en am still trying to learn it if you could help i would really appreciate it. Here is my code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class levelGenerator : MonoBehaviour { [SerializeField] private Transform levelPart_Start; [SerializeField] private Transform levelPart_1; private void Awake() { Transform lastLevelPartTransform; lastLevelPartTransform = SpawnLevelPart(levelPart_Start.Find("EndPosition").position); lastLevelPartTransform = SpawnLevelPart(lastLevelPartTransform.Find("EndPosition").position); lastLevelPartTransform = SpawnLevelPart(lastLevelPartTransform.Find("EndPosition").position); lastLevelPartTransform = SpawnLevelPart(lastLevelPartTransform.Find("EndPosition").position); lastLevelPartTransform = SpawnLevelPart(lastLevelPartTransform.Find("EndPosition").position); lastLevelPartTransform = SpawnLevelPart(lastLevelPartTransform.Find("EndPosition").position); } private Transform SpawnLevelPart(Vector3 spawnPosition) { Transform levelPartTransform = Instantiate(levelPart_1, spawnPosition, Quaternion.identity); return levelPartTransform; } }
@rudders8054
@rudders8054 4 жыл бұрын
same. you find a fix?
@oystudios3052
@oystudios3052 4 жыл бұрын
@@rudders8054 yes, i am a bit more familliar with unity now. I don't know if this is what i did wrong because this was 2 months ago. What i think you need to do is check if you assigned your levelpartstart to a gameobject in the scene or a prefab, if you have it selected as a prefab then the solution is to already have the levelpartstart in game or just use an empty game object to then put it in the serializefield of the editor and change the way the first part spawns just to that point (the transform of the gameobject) What this error actually means is that the reference you made (probably a GameObject variable) is empty, so it couldn't get that GameObject. Alternatively you can make the game simpler by using a linear approach with no height differences, blackthornprod has a tutorial for this wich I ended up using instead of this one: kzbin.info/www/bejne/a36ap4uVr5t1b6s If you do want to go further with this one you can check the unity docs and threads about this error I will link the unity docs page here: docs.unity3d.com/Manual/NullReferenceException.html
@rudders8054
@rudders8054 4 жыл бұрын
@@oystudios3052 the serializefield starting point fixed it. Thankyou SO much. i'll check the other tutorial too
@oystudios3052
@oystudios3052 4 жыл бұрын
@@rudders8054 no problem, happy I could help :)
@tizianaminerva2470
@tizianaminerva2470 4 жыл бұрын
@@oystudios3052 could you explain it more?
@danielmakac3686
@danielmakac3686 5 жыл бұрын
Hey, CodeMongkey Awesome Tutorial! I really love it! Am, Can you make a tutorial video about making a grappling hook system in unity2D. that would be awesome! there not many tutorials about it.
@CodeMonkeyUnity
@CodeMonkeyUnity 5 жыл бұрын
Yes a grappling hook is definitely something I have on my list, not sure when though.
@danielmakac3686
@danielmakac3686 5 жыл бұрын
@@CodeMonkeyUnity Thank you so much.
@soma_donat
@soma_donat 4 жыл бұрын
I would like to see that in 2D too :) there are no good tutorials of that
@solecito69
@solecito69 3 жыл бұрын
No entiendo por qué la gente se queja por este aporte, a mi parece está muy bien implementado, solo basta con poner algo para que se destruya automáticamente para que el rendimiento no afecte. Y eso que les da GRATIS, se quejan. Además tengan en cuenta que la manera en que se instancia los objetos es a razón de X e Y, si la posición de x = 0, todos los bloques irán perfectamente en vertical y viceversa. Solo deben checar cómo funciona esto, y funciona bien.
@TheCyborgCast
@TheCyborgCast 4 жыл бұрын
With the private Player player; part gets me confused on what 'Player' is that the player movement script?
@klareks542
@klareks542 3 жыл бұрын
I have the same problem,I dont know how to fix it.
@BigFrogOfWar
@BigFrogOfWar 3 жыл бұрын
i have it also :(
@ltcSpitfire
@ltcSpitfire 4 жыл бұрын
When I try to instantiate LevelPart_1, even though the EndPosition is at the same height as the LevelPart_Start, the cloned prefabs spawn lower than each other over time. If I raise the EndPosition on the LevelPart_1 compared to LevelPart_Start, the first clone is lower then it begins to climb. I'm totally lost as to why.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Check the origin of your level parts, add some Debug.Logs to verify that the EndPosition is what it should be
@ltcSpitfire
@ltcSpitfire 4 жыл бұрын
@@CodeMonkeyUnity Yeah it was the prefabs origin, it had moved.. sleeping on it helped see it haha plus my placeholder sprites aren't the best to represent a flat platform. Thank you.
@ltcSpitfire
@ltcSpitfire 4 жыл бұрын
@@CodeMonkeyUnity How would I destroy the start and other prefabs after they have been used and are out of the camera view?
@christinerichard4198
@christinerichard4198 3 жыл бұрын
Please guys help me support this new Endless Runner, im sure you'll love it and it'll really help the devs out play.google.com/store/apps/details?id=com.ObinnaStudios.TheCollectors
@mineungkim4599
@mineungkim4599 2 жыл бұрын
HI, I was wondering, If I didn't want the levels parts to spawn higher or lower from the previous ones how would I go about doing it? I'm trying to make an endless grapple hook game and even if I made the endpoints the same from the level start the level parts still keeps on inclining slightly. I just don't want the level parts to go over or under a specific area since I'm planning on adding a ceiling as well as a lava pit. thank you in advance.
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
If the end point is at the same height as the start point then it will always stay at that height
@mineungkim4599
@mineungkim4599 2 жыл бұрын
@@CodeMonkeyUnity Hi, thank you but where is the start point? is it the position of the level part start? And if so how do I put them at the same height? thank you
@kagigreenscreen
@kagigreenscreen 5 жыл бұрын
hi nice tutorial . i got the package and every time i try to add the package it crashes unity just when it gets to 'small assets ' Please help with this Thanks
@blaaablooo5233
@blaaablooo5233 4 жыл бұрын
if u have a lot of players so your Player variable needs to be an array or list so if u tried to access the setters and getters u cant so my question is if I have many players so instead of refrence it like u did from th eeditor I need to findgameobject of that type(player) In code or there is some thing else I can do I am a beginner thanks and sorry for my bad English
@nantohola4427
@nantohola4427 3 жыл бұрын
I have two questions, Should I always use Quaternion.identity everytime I instatiate something? What is the actual function of Quaternion and the identity used on it, I use on instinct and never truly understood if there are more applications for it.
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Quaternions are used for defining rotation, the identity matrix simply means no rotation which is usually what you want when working with 2D objects
@ThinkForward0
@ThinkForward0 4 жыл бұрын
mine is 3D HyberCasual Game , when i did the spawning with the same prefab ( which has 2 obstacles in it ) it kept producing 1 obstacle then 2 obstacles instead of the 2 from the prefab , can some one please help
@romeo4333
@romeo4333 3 жыл бұрын
Hey, this tutorial helped me a lot, but I ran into 1 problem: The generation stops at a certain point depending on this number: private const float PLAYER_DISTANCE_SPAWN_LEVEL_PART = 250f; I haven't seen anyone got this problem too so I hope it is just an easy fix. Help would be really appreciated!
@brunosoares6717
@brunosoares6717 2 жыл бұрын
i have the same problem, and dont find the solution yet EDIT** i find one solution that works for me, in my virtual camera who controls the main camera i have set the camera distance to 20, so i just set it to a higher number and works =)
@doctorpizza8518
@doctorpizza8518 11 ай бұрын
this happens because your level parts / end positions have a different z value from zero, so you don't notice it but they get further away from player, moving along the z axis until they are so far away the distance condition stays false. to fix, set all your level parts and end positions with z = 0
@christinerichard4198
@christinerichard4198 3 жыл бұрын
My friend recently finished an endless runner called The Collectors and he would really like some support. Ive downloaded the game and it's pretty fun
@craftercis
@craftercis 3 жыл бұрын
I played the game ;). It looks fun and the controls are fine. Only - point is the UI. Its to busy on the screen.
@christinerichard4198
@christinerichard4198 3 жыл бұрын
@@craftercis wow..Thank you so much, I'll be sure to tell him
@christinerichard4198
@christinerichard4198 3 жыл бұрын
You can send him some feedback, I'm sure he'll appreciate it ☺
@Kogsworth
@Kogsworth 4 жыл бұрын
Will you run into a problem where your position is too far from 0,0 at some point? Like the numbers will be too big for the CPU to handle?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
The float.MaxValue is a massive amount so it's extremely unlikely unless for some reason your characters are 10000 units wide.
@aleksp8768
@aleksp8768 3 жыл бұрын
how can i do this if the platforms are made from a tilemap?
@hugabuga-il6125
@hugabuga-il6125 4 жыл бұрын
Thanks💓💓
@zinedinemaylano2308
@zinedinemaylano2308 13 күн бұрын
hello, i have a question, can u tell me how to implement the GENETIC ALGORITHM from Procedural Content Generation to game like this?
@knowledgeseeker8735
@knowledgeseeker8735 6 күн бұрын
For some of you out there, you might be stuck on the first step after instantiating. When you go to fill out the serialize field, drag the prefab from the project tab, NOT the hierarchy. This makes sure when you delete it, the Serialize Field is still filled because it's not looking for it in the hierarchy, but instead in the Project Tab
@CodeMonkeyUnity
@CodeMonkeyUnity 5 күн бұрын
Yeah always make sure you use prefab references from the project files and not the scene, otherwise you will get some strange errors if the scene object is destroyed
@knowledgeseeker8735
@knowledgeseeker8735 Күн бұрын
@@CodeMonkeyUnity Yoooo ur still active on this vid?
@artsurock
@artsurock 2 жыл бұрын
Hi! I have a problem, i'm doing a 3d endless runner and i used the same code. For first 5 platforms it works nice but after platforms start to appeare in the right places, however they are invisible. I checked layers but these platforms have same layer with first five platforms, other components same too, i wrote similar code but with other approach and it works simmilar, first five platform are visible and other not, please help me if you know what i 'm doing wrong
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Check the Z position, everything should be on Z = 0 If your endPoint is on a different Z then every new platform will be further and further away from 0 until its behind the camera and you can't see it
@minedeath_gt
@minedeath_gt 4 жыл бұрын
Hi can you help me with a problem?, when i run the code it says the namespace Player could not be found.
@jaristossmith9125
@jaristossmith9125 4 жыл бұрын
I believe I ran into the same problem. I created a separate script named "Player" and inside I wrote this: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { public Vector3 GetPosition() { return transform.position; } } I then attached this script both to the object "LevelGenerator" and the actual player object as their components.
@wethescooters5119
@wethescooters5119 4 жыл бұрын
@@jaristossmith9125 yay thanks
@jaristossmith9125
@jaristossmith9125 4 жыл бұрын
@@wethescooters5119 No problem :)
@uditwarikoo266
@uditwarikoo266 4 жыл бұрын
@@jaristossmith9125 thanksssssss... I've been looking for a solution for so long!!!!
@christinerichard4198
@christinerichard4198 3 жыл бұрын
Please guys help me support this new Endless Runner, im sure you'll love it and it'll really help the devs out play.google.com/store/apps/details?id=com.ObinnaStudios.TheCollectors
@Arab_GameDev
@Arab_GameDev 2 жыл бұрын
thank you
@synthwave_4144
@synthwave_4144 4 жыл бұрын
The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference? What is happening?
@gamingstudio482
@gamingstudio482 4 жыл бұрын
I think....you...mm...you should use.... i dont know i dont have Unity YET
@SADIAPOM
@SADIAPOM 4 жыл бұрын
Hello, in case you still haven't found the answer, I fixed this by making it into a private Transform player and change it to player.position instead of player.GetPosition - Hope this helps
@nz9531
@nz9531 3 жыл бұрын
This means that you haven't made a script with the namespace Player
@modakdid
@modakdid 3 жыл бұрын
@@SADIAPOM When I do that I get the non invocable member Transform.position cannot be used like a method
@tobi6758
@tobi6758 3 жыл бұрын
@@modakdid me too
@nauvalnavis6673
@nauvalnavis6673 2 күн бұрын
at 12:24 you were making new gameobject for levelpart2, and place the levelpart 2 at the end part1, my issues is why mine is different? when i put object inside the levelpart2 for platform, the levelpart2 gameobject change position? my levelpart2 "pivot" were at the center of platform instead of end of the part1, i hope you understand my words because im stuck here and this problem making my platform generation scrambled
@CodeMonkeyUnity
@CodeMonkeyUnity Күн бұрын
Maybe your tool is set on Center instead of Pivot unitycodemonkey.com/video.php?v=qa5WBatZ830 Make sure you're checking the actual transform position
@nauvalnavis6673
@nauvalnavis6673 Күн бұрын
@@CodeMonkeyUnity thanks you helped me alot twice in another video, even those video were from many years ago
@andryfiderana4767
@andryfiderana4767 2 жыл бұрын
One pretty big concern on this video is the approach of infinite runner , usually you'll want to avoid moving across the world, instead moving the world towards you. Otherwise you'll run into distance issues
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
That is only an issue if you move an insane amount, so in this case you'd have to player the game non-stop without losing for several days before you start to get float imprecision.
@andryfiderana4767
@andryfiderana4767 2 жыл бұрын
@@CodeMonkeyUnity Yes but only if your game's speed is like this, but its kinda limited, and goes against the concept of "infinite runner".I think most of infinite runner games are more fast paced , with increasing speed over time. So i would still strongy not recommend this kind of approach in any case
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
​@@andryfiderana4767 As always you need to make your systems suitable for whatever design you're trying to create, so if your game involves hyper speed then yes you would need a different approach. But keep in mind floats only start losing precision at insanely high values (higher than trillions) so even if your character runs super fast and your runs last for hours it's highly unlikely you will reach that problem.
@AliskHD
@AliskHD 3 жыл бұрын
Hey, I used your tutorial and all worked fine till the moment I wanted to change the x y thing to the End Point Variable... Now my Generator works fine, it spawns the LevelPart_1 to the End Position but I have no idea why those platforms are invisible in the Gamemode, if I swop to the scene till the Game runs, I can see that generated LevelPart_1s but in the Gamemode, they are as I said invisible and I have no clue why... Also funny to know is that my player can jump on those invisible ones and also can collect coins on it. Please help me I stuck with this problem for now about 3 days and I can't find my mistake.
@AliskHD
@AliskHD 3 жыл бұрын
Nvm I found my mistake in the comments xD
@Burakjones42
@Burakjones42 3 жыл бұрын
@@AliskHD what is it pls help me
@StockMarket_FinanceEducation
@StockMarket_FinanceEducation 2 жыл бұрын
I have a problem with the Endposition because the distance between levelpartstart and levelpart_1 is too far away for the Player Pls help
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
What problem? EndPosition is where the next level part will be spawned.
@StockMarket_FinanceEducation
@StockMarket_FinanceEducation 2 жыл бұрын
@@CodeMonkeyUnity yeah that is right but when i start the game the distance between levelpartstart and levelpart1 is very far so have you an idea to fix this problem
@xoduk
@xoduk 2 жыл бұрын
I know this was forever ago, but how would you go about creating biomes/worlds. Not just have random parts be different, like pick from a list 0, 1, 2... and if its biome 0 pick from this arrayList to spawn parts, else if biome 1 use this arrayList to spawn parts. I feel like I could figure it out but wanted to make sure I don't do it wrong and I don't see any tutorials for it.
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Have multiple lists for each different biome. Then maybe you select the biome based on distance, every 100 units the player moves you randomly pick the next biome. Then pick the next parts from the selected biome list
@LostDeception
@LostDeception 4 жыл бұрын
Hm when getting the level start position using ("EndPosition").position it makes my object sprite not render. Using the new Vector3(x,y) seems to work fine.. i am a tad confused lol
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Check the Z position, if you have it as a non-zero value eventually the platforms will start being spawned behind the camera.
@harikrishnaes484
@harikrishnaes484 3 жыл бұрын
can anyone help me all my scenes and all the game i developed have now came into an error and there is no scenes in there completely empty this was writteninconsole "Unknown error occurred while loading 'Assets/Scenes/SampleScene.unity'."
@siddisking
@siddisking 4 жыл бұрын
Why are you using multiple types of cases in a single file? I am new to c# so don't know much about using snake, pascal and camel case together. If there a reason for doing this?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
I use PascalCase for class and function names and camelCase for variables. Only use Snake case when I feel like I need to add more "grouping" to a some name so very rarely.
@faraday3833
@faraday3833 4 жыл бұрын
Hey Code Monkey this tutorial is so good. But i have a question about this automatic level generation system. If player falls from platform player should die. So i tried to add empty game object with 2D box collider under each level part but its not working right. That box collider can touch to other level parts. So what should i do?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
The simplest way is to use the player Y velocity and if it's too big you kill the player.
@faraday3833
@faraday3833 4 жыл бұрын
@@CodeMonkeyUnity Oh how i couldn't think this! Very simple solution! Thank you so much you are awesome!
@theUnfrench
@theUnfrench 10 ай бұрын
I wanna preface this by saying i haven't touched Unity in a good few months. Currently having a small problem with the "private Player player" biy here. I have a Player game object, and a PlayerMover script. When I try "private Player player", it gives the red squiggly line. "private PlayerMover player" doesn't give the squiggly, but then it doesnt give the option for "GetPosition". I tried to grab the rigidbody in the PlayerMover script and get its position, but that either didn't work, or I didn't do it right. Any correction you can provide would be pretty great rad 🤙
@CodeMonkeyUnity
@CodeMonkeyUnity 10 ай бұрын
If you don't have any class named exactly Player then it gives an error. For a GetPosition() function you probably just want to get the transform.position
@MrSmoofist
@MrSmoofist 3 жыл бұрын
So i ran into a weird problem: After a while, some of the level parts suddenly spawn with a random large number on the Z in the position, which makes them invisible in-game since they're out of the camera's reach, i went trough the code and found nothing that sets the Z for them so randomly, any idea why?, Also when it happens, it happens randomly to one of the parts and stops after a bit
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Check the Z position of the EndPoint, that's where the platforms are spawned so if that object has a non-zero Z it will constantly add onto the spawned platform Z.
@MrSmoofist
@MrSmoofist 3 жыл бұрын
@@CodeMonkeyUnity So apparently some of the prefabs changed their Z after i press play even tho they were 0 before that. after remaking the prefab it stopped, thank you for the quick reply!
@MyRapper34
@MyRapper34 4 жыл бұрын
HELP I want my map side by side I mean ground position always be the same , how can I do this in this script HELP
@sagarrawal5195
@sagarrawal5195 4 жыл бұрын
can anyone please tell me how to make and image as an platform for the player to run im very beginner i only want make an 2d endless runner or a runner game with levels but there are good tutorial out there
@larsmaasanimaties4594
@larsmaasanimaties4594 3 жыл бұрын
i have a error by the line: if (Vector3.Distance(player.GetPosition(), lastEndPosition) < PLAYER_DISTANCE_SPAWN_LEVEL_PART) this is the error: Assets/Scripts/LevelGenerator.cs(27,33): error CS1061: 'Player' does not contain a definition for 'GetPosition' and no accessible extension method 'GetPosition' accepting a first argument of type 'Player' could be found (are you missing a using directive or an assembly reference?)
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
You don't have any function named "GetPosition" in your Player class
@larsmaasanimaties4594
@larsmaasanimaties4594 3 жыл бұрын
@@CodeMonkeyUnity thanks! But what must be in that function? (Sorry for my bad english)
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
@@larsmaasanimaties4594 You return the position of the object, usually just "return transform.position;"
@larsmaasanimaties4594
@larsmaasanimaties4594 3 жыл бұрын
@@CodeMonkeyUnity then i got this error: Assets/Scripts/Player.cs(86,7): error CS0127: Since 'Player.GetPosition()' returns void, a return keyword must not be followed by an object expression
@ubormaci5322
@ubormaci5322 4 жыл бұрын
In my script it don't gets the player. In "[SerializeField] private Player player;" the system never finds a player, it just questions "Type or namespace 'Player' could not be found (etc.).
@GaviTSRA
@GaviTSRA 4 жыл бұрын
I had the same Problem. you make a script on the Player named Player. In the Player script you do: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { public Vector3 GetPositionPlayer; public void Update() { GetPositionPlayer = gameObject.transform.position; } } and in the random Generation script you do: private void Update() { if(Vector3.Distance(Player.GetComponent().GetPositionPlayer, lastEndPosition ) < PLAYER_DISTANCE_SPAWN_LEVEL_PART) { SpawnLevelPart(); } } thats my soluion. i dont know if there is a bedder one but it works
@Unexplained65
@Unexplained65 4 жыл бұрын
I was hoping you would have some kind of way to dump the old prefabs after they were off screen for too long but i will be poking around at how to do that one myself
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Just a simple Distance check would work, cycle through all the level parts and do if (Vector3.Distance(levelPartPosition, playerPosition) > distanceToDestroy) Destroy(levelPart);
@d-o-double-g42
@d-o-double-g42 4 жыл бұрын
Hello. i have a question is it possible to make it so that the longer you press jump button the higher you jump with a jump limit?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Define a float field and increase it by Time.deltaTime while Input.GetKey(); is pressed
@d-o-double-g42
@d-o-double-g42 4 жыл бұрын
@@CodeMonkeyUnity Ok thank you
@jayjohnson4143
@jayjohnson4143 Жыл бұрын
Where should I implement the 'Player' class? I've tried importing it into the levelGenerator script and it doesn't seem like I have one?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Wherever you want, it can be anywhere in your code base, you can use whatever player controller you want, the Level Generator doesn't care
@jayjohnson4143
@jayjohnson4143 Жыл бұрын
This may sound stupid but what did you mean by "remove the prefav from our scene". Did you mean delete it? My prefab does not seem to generate.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Yes delete the prefab from the scene, it is meant to be spawned dynamically and not be there by default But do make sure the LevelGenerator script is running, it shouldn't be running on the Part prefab
@jayjohnson4143
@jayjohnson4143 Жыл бұрын
@@CodeMonkeyUnity Thank you for your help, also, with making the scene generate endlessly, it does not give me the box to assign the Player to the level generator script?
@Morox3_
@Morox3_ 4 жыл бұрын
I have this error message please help; Assets\LevelGenerator.cs(11,30): error CS0246: The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?)
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
You dont have any class named "Player" in your project
@statesmancomics7284
@statesmancomics7284 4 жыл бұрын
im very close to being done with my game or so i thought when i went for a full test i noticed that my endless runner stops between 20 -42 levelparts and always on my 4thlevelpart but it uses the 4thlevelpart without issue inbetween but always ends on it and stops auto generating any idea why?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Pause and check the Z position, it should be 0, it not then you're increasingly spawning platformers on a higher Z which eventually spawns behind the camera
@statesmancomics7284
@statesmancomics7284 4 жыл бұрын
@@CodeMonkeyUnity i noticed it was doing that but shouldnt they still show up in the hierarchy which its not? it just stops creating them
@statesmancomics7284
@statesmancomics7284 4 жыл бұрын
@@CodeMonkeyUnity i checked it its pushing the z axis to 99.something before it stops spawning but would that stop it from creating new platforms also how do i fix this? thanks for the help im in love with your videos
@under4829
@under4829 Жыл бұрын
Hey, I have a lil problem taht make it impossible to do it, Unity tell me that the Player (The thing u put behind SerializedField) doesn't exist, it propose me PlayerPrefs, but then it say that GetPosition don't work with that :( I'm beginner so I would be really happy if you'd help me!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Sounds like you don't have any class named "Player"
@cyberguygame9096
@cyberguygame9096 3 жыл бұрын
@Code Monkey I want to destroy all the spawned GameObjects and create new ones each time I die. How can I do that? I tried adding the spawned parts to a list and destroy them each time I die and call the levelgenerator when I am starting again. but that seems not like the best way.
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
That is indeed the best way, add them to the list when spawned, removed them from the list after you destroy them.
@gorsayamyan1632
@gorsayamyan1632 3 жыл бұрын
Hi, I have a question about the platform behavior. Is it possible to modify the platform as in the game tiny wings in IOS or Dune in android. I am new in game developement thank you for advance ))
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Sure, after spawning the platform you can do whatever you want with it like stretch it, rotate, move, etc.
@Mammadexe
@Mammadexe 3 жыл бұрын
hi i want to destroy the instantiated objects after i pass them but when i use Destroy(levelPart) it says i couldnt destroy transforms
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
You need to destroy the game object Destroy(transform.gameObject);
@ZeeEmeraldLad
@ZeeEmeraldLad 4 жыл бұрын
Everything was going smoothly in my follow-through until I got to "[SerializeField] private Player player; " I keep getting an error that says " the type or namespace 'Player' could not be found (are you missing a using directive or an assembly reference?)" I am way too inexperienced to figure out where I went wrong.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Sounds like you dont have any class in your game named Player
@marus960
@marus960 4 жыл бұрын
Code Monkey Can you help me by telling me what can i do to make a class named player? I am new in Unity...
@GaviTSRA
@GaviTSRA 4 жыл бұрын
You give the Player a script named Player. In the Player script you write: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { public Vector3 GetPositionPlayer; public void Update() { GetPositionPlayer = gameObject.transform.position; } } and in the random Generation script you do: private void Update() { if(Vector3.Distance(Player.GetComponent().GetPositionPlayer, lastEndPosition ) < PLAYER_DISTANCE_SPAWN_LEVEL_PART) { SpawnLevelPart(); } } thats my solution. i dont know if that is the best but it work
@miraimui552
@miraimui552 4 жыл бұрын
@@GaviTSRA Thanks dude, that' so helpful to me
@GaviTSRA
@GaviTSRA 4 жыл бұрын
@@miraimui552 ;D
@anshulsingh8326
@anshulsingh8326 Жыл бұрын
Sometimes player just get little inside the ground collider after falling from high places. How to fix it? It doesn't happen always and it happens randomly at different places.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Change the rigidbody collision detection to Continuous instead of Discrete
@kingcreatez4827
@kingcreatez4827 2 жыл бұрын
i have an error at 10:34 😭, it says "Assets\scripts\LevelGenerator.cs(11,29): error CS0246: The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?)" please can you help?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Sounds like you don't have any class named "Player" in your game
@gameofcharging
@gameofcharging 3 жыл бұрын
Hey, I have a question. What's the difference between Awake and Start method?
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Awake(); runs before Start();
@MinecraftTVGameplay
@MinecraftTVGameplay 5 жыл бұрын
Hi Code Monkey!Great tutorial!But i have to ask you,can you make a tutorial about making a random generated map where you jump through holes like in a helix jump but in 2d?Thank in advice.
@CodeMonkeyUnity
@CodeMonkeyUnity 5 жыл бұрын
Like Super Hexagon? That is indeed a relatively simple game that I'd like to cover some day.
@MinecraftTVGameplay
@MinecraftTVGameplay 5 жыл бұрын
@@CodeMonkeyUnity Wow,such a amazing game,sure,you can make a tut about that.
@alicadus
@alicadus 4 жыл бұрын
ok so my platforms when i isntantiate them come out as invisible, and only reach up to 5 platforms even though i made the for loop. i need help. its on a canvas but i didnt make the platforms children of the canvas nor the player sprite. though the player sprite only jumps while it remains still and the platforms are the ones that moves to the left. i need help
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Check the Z position, make sure theyre not spawning behind the camera
@alicadus
@alicadus 4 жыл бұрын
@@CodeMonkeyUnity the camera is -10 and the cloned platforms are 0. They still appear invisible. Could it be the empty objects that are affecting them?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
@@alicadus Are they on a layer that the camera is rendering? Is there something in front? Can you see them when you pause the game using the editor camera?
@rezureax374
@rezureax374 3 жыл бұрын
@@CodeMonkeyUnity Hey i have the same problem
@phatcharaponchaiyapong4370
@phatcharaponchaiyapong4370 2 жыл бұрын
error CS1061: 'Player' does not contain a definition for 'GetPosition' and no accessible extension method 'GetPosition' accepting a first argument of type 'Player' could be found (are you missing a using directive or an assembly reference?) What do I need to do to fix it?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Make a function called GetPosition(); that just returns the transform.position
@mtyuiop07
@mtyuiop07 2 жыл бұрын
​@@CodeMonkeyUnity How? I'm trying it but I can't return the transform.position
@Arab_GameDev
@Arab_GameDev 2 жыл бұрын
anyown have the same problem : refrence Player , .... you can go with "private Transform player" &&&& in the GetPosition you can write "player.transform.position" it Works . this's all the problem i VS in this tuto
@kidimaus1
@kidimaus1 2 жыл бұрын
pmg thank you so much. when i did the player.GetPosition it didnt work but somehow it did in the video. i went crazy and you reallly really helped
@anshulsingh8326
@anshulsingh8326 Жыл бұрын
Is there any way to know exactly which level part is instantiated ? Like I want to add a constraint that if the last level part id or tag was 2 than instantiate another level part.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
You could put the level parts inside a ScritpableObject and use that to identify exactly what part you spawned unitycodemonkey.com/video.php?v=7jxS8HIny3Q
@anshulsingh8326
@anshulsingh8326 Жыл бұрын
@@CodeMonkeyUnity thanks
@11hilas
@11hilas 3 жыл бұрын
Hello, iam using Unity Version 2020.1.9f1 and i have the problem that this Line: "[SerializeField] private Player player;" dont works. It says to me that a Type called "Player" doesnt exists. Please help me!
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
You don't have any class named "Player"
@SociopathDev
@SociopathDev 5 жыл бұрын
Hey, newbie question when to use SerializeField? thanks for your tutorials btw!
@mehmedcavas3069
@mehmedcavas3069 5 жыл бұрын
Its for variables which are private. You can see public variables in the unity inspector but not private ones. However, when you add [SerializeField], your variable is still private but you can access it from the unity inspector. Try your self to see your variable in the inspector with serializefield and without :)
@DexterDLopez
@DexterDLopez 5 жыл бұрын
You use SerializeField on a private variable when you want to see it and modify it in the inspector while also keeping it protected from other scripts from accidently using it
@SociopathDev
@SociopathDev 5 жыл бұрын
Thanks I understand it now, and another newbie question, what about serializable?
@DexterDLopez
@DexterDLopez 5 жыл бұрын
@@SociopathDev I'm not 100%, but I think it makes a script that's not attached to an object accessible via script. Try looking the term up in Documentation on Unity's site
@mehmedcavas3069
@mehmedcavas3069 5 жыл бұрын
@@SociopathDev lets say you created a normal class which is not monobehavior. When u create an object of this class in another monobehavior u cant see it event when it is public. you can see it when u write System.Serializable over the class. If want i can give an example :)
@ProdByShark
@ProdByShark 2 жыл бұрын
when I add serializefield private Player player, I get this error The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?) HELP!!
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Sounds like you don't have any class in your project named "Player"
Random Map Generator in UNITY! [Tutorial]
10:49
Garnet
Рет қаралды 25 М.
[柴犬ASMR]曼玉Manyu&小白Bai 毛发护理Spa asmr
01:00
是曼玉不是鳗鱼
Рет қаралды 49 МЛН
MOM TURNED THE NOODLES PINK😱
00:31
JULI_PROETO
Рет қаралды 15 МЛН
1🥺🎉 #thankyou
00:29
はじめしゃちょー(hajime)
Рет қаралды 78 МЛН
Parallax Infinite Scrolling Background in Unity
17:11
Code Monkey
Рет қаралды 146 М.
Trying to Make Terraria in One Week | Unity Game Devlog
6:35
Endless Runner Level Generator (Difficulty + Highscores) in Unity
17:28
RANDOM DUNGEON GENERATOR - EASY UNITY TUTORIAL - #1
7:47
Blackthornprod
Рет қаралды 364 М.
MAKING RUN, IDLE & JUMP 2D GAME ANIMATIONS - UNITY TUTORIAL
15:30
Blackthornprod
Рет қаралды 507 М.
5 Minute ENDLESS RUNNER Game UNITY Tutorial
5:10
BMo
Рет қаралды 103 М.
What are Events? (C# Basics)
15:05
Code Monkey
Рет қаралды 372 М.
[柴犬ASMR]曼玉Manyu&小白Bai 毛发护理Spa asmr
01:00
是曼玉不是鳗鱼
Рет қаралды 49 МЛН