How To: Codelock - Unity Tutorial

  Рет қаралды 7,450

Aeonic Softworks

Aeonic Softworks

Күн бұрын

Пікірлер: 38
@paperbob4302
@paperbob4302 5 жыл бұрын
Hey there this is really cool, one question I have tho is how i could add audio ques to if i get the code wrong or if you press the button or something like that
@aiken1983
@aiken1983 2 жыл бұрын
Sir, I love you so so so so much. this video has super helpful!
@Taarmut
@Taarmut 6 жыл бұрын
Great video! I'm making my first game just for fun and this was very helpful. Thanks!
@aeonicsoftworks6370
@aeonicsoftworks6370 6 жыл бұрын
Thank you for your kind words, i'm glad to have been able to help you out.
@EdwinCreatives
@EdwinCreatives 5 жыл бұрын
Any way to make it rotate 2 doors at the same time??? I am making 2 doors... Should I assign the script to Parent?
@aeonicsoftworks6370
@aeonicsoftworks6370 5 жыл бұрын
You certainly can use this to open two doors at the same time to do so, change.... Line 13: public Transform toOpen; to.... public Transform toOpen1, toOpen2; and drag your doors into the scripts transform slots in the inspector also change the Open IEnumerator to..... IEnumerator Open () { toOpen1.Rotate(new Vector3(0,90,0),Space.World); toOpen2.Rotate(new Vector3(0,90,0),Space.World); yield Return new WaitForSeconds(4); toOpen1.Rotate(new Vector3(0,-90,0),Space.World); toOpen2.Rotate(new Vector3(0,-90,0),Space.World); } This should open both doors at the same time from the same lock. I'd also like to suggest potentially changing the toOpen variable to be an array containing both the doors, then use a for loop to iterate through that array in the Open IEnumerator and call Rotate() on each Transform before and after the yield return new WaitForSeconds(). With the respective values ofcourse. Either will work. The second is just a bit more tidy. If you'd prefer the second and have trouble implementing it yourself, let me know and I'll reply with a solution in a follow up comment.
@EdwinCreatives
@EdwinCreatives 5 жыл бұрын
I don’t wish to keep changing but I want it to auto change every time I reset the game... Is there a way? Otherwise I have to change it every time when i publish...
@EdwinCreatives
@EdwinCreatives 5 жыл бұрын
I meant the code
@aeonicsoftworks6370
@aeonicsoftworks6370 5 жыл бұрын
@@EdwinCreatives Indeed, Add this to your codelock script, at line 14 void Start(){ code = Random.Range(x,y).ToString(); } x being your lowest accepted value, y being the highest. ex: Random.Range(1, 9999). You can also make x and y into public int variables you can use to set as min a max from the inspector instead of the code itself.
@EdwinCreatives
@EdwinCreatives 5 жыл бұрын
@@aeonicsoftworks6370 Sorryyyyy... I have have another question😅 How to make a the paper change its number together with the code? Do I use back the same line?
@marijnbaas3829
@marijnbaas3829 2 жыл бұрын
how do you make this work with a first person camera inside a empty player object?
@nikkowh
@nikkowh 2 жыл бұрын
Thanks for turorial man! Its the best one I found! Not sure if u are still active but is there a way how to show player what he pressed? If its like this u can see it only in project, not in game :/ For those who don´t want to rewrite it all: CodeLock: using System.Collections; using System.Collections.Generic; using UnityEngine; public class CodeLock : MonoBehaviour { int CodeLenght; int placeInCode; public string code = ""; public string attemptedCode; public Transform toOpen; private void Start() { CodeLenght = code.Length; } void CheckCode() { if (attemptedCode == code) { StartCoroutine(Open()); } else { Debug.Log("pica"); } } IEnumerator Open() { toOpen.Translate(new Vector3(2, 5, 10), Space.World); yield return new WaitForSeconds(60); toOpen.Translate(new Vector3(-2, -6, -10), Space.World); } public void SetValue (string value) { placeInCode++; if (placeInCode
@johnex3537
@johnex3537 4 жыл бұрын
could this have a randomly generated password or pick between a number of passwords
@peimingtan623
@peimingtan623 5 жыл бұрын
How to make the door just positioning not rotate? Move to left or right . thanks
@NotEdwinDev
@NotEdwinDev 5 жыл бұрын
you could always use animation for that but I am struggling from the script and still able to help and happy to help.
@NotEdwinDev
@NotEdwinDev 5 жыл бұрын
You can also do as the video shown 2:08
@aeonicsoftworks6370
@aeonicsoftworks6370 5 жыл бұрын
To make it behave like a sliding door you can use transform.Translate() instead of transform.Rotate() to do so Replace.... toOpen.Rotate() on lines 25 and 29 with toOpen.Translate(x,y,z) x, y and z being the amount you wish to move the object in world space. I cannot give you exact numbers here but with a little tweaking I'm sure you can find the correct values. Also make sure you reverse the values on line 29.
@andhikariptayudo8921
@andhikariptayudo8921 4 жыл бұрын
how to insert reset button?
@noaholmgren3442
@noaholmgren3442 4 жыл бұрын
it doasnt work at all for me. Nothing happens but i have no errors
@AB-nh4dn
@AB-nh4dn 4 жыл бұрын
same here!!
@walidbenothmen7741
@walidbenothmen7741 2 жыл бұрын
great video but i get the error CS1503: Argument 1: cannot convert from 'void' to 'string'
@aeonicsoftworks6370
@aeonicsoftworks6370 2 жыл бұрын
Can you tell me what time it is you write this line of code that throws the error?
@liamperkins398
@liamperkins398 6 жыл бұрын
I've been trying to make a 3D keypad for days you finally solved it for me thank you!
@aeonicsoftworks6370
@aeonicsoftworks6370 6 жыл бұрын
Glad to help buddy!
@Souly995
@Souly995 5 жыл бұрын
Hello Good sir i hope you doign well i was just wondering is it possible if i apply this on a chest with my own animation or i cant
@aeonicsoftworks6370
@aeonicsoftworks6370 5 жыл бұрын
You can indeed apply this to a chest. You could replace the door to be the top of a chest to visually display the opening of the chest. If your chest has loot, you can make the loot available to the player on successfully entering the code. I hope this helps you out and if your unsure about how to do that please let me know and ill be happy to give a hand :).
@Souly995
@Souly995 5 жыл бұрын
​@@aeonicsoftworks6370 Thank you so much buddy for replying back means alot it would be really great actually ,because i noticed your script has a door rotation which means the only way that animation will work is by rotating the door or any object to 90 degrees, but i dont want that , because i already have my own animation for the chest so i want to apply it there but i dont know how to make it work . Anyway ill probably try it out and see if i can if not then ill make sure to contact you . Thanks again for your time and you gained a subscriber
@vixdle7032
@vixdle7032 5 жыл бұрын
How could I make it react to my crosshair instead of my camera? I'm trying to do this in first person and it seems difficult
@aeonicsoftworks6370
@aeonicsoftworks6370 5 жыл бұрын
This should work aslong as.. Your code is the same Your crosshair(which i assume is a gameObject and is sitting at your mouse position). does not collide with the ray. Your reachRange is long enough(try making this number larger) If these are the case and its not working. Please add this to line 27... Debug.Log(hit.collider.gameObject.name); Save the project then start it up. Once its running, you are in the reach range and are looking at a gameObject with a collider the ray can collide with, you will get a debug.Log() in your console panel, Let me know what this says when your looking at the codelock. Id also suggest turning on collapse in your console window to stop your console window getting spammed by the Debug.Log(). By default its the second option in the top mounted hot bar.
@2ksnakenoodles
@2ksnakenoodles 3 жыл бұрын
The crosshair should be a UI element, so just get a ray forward from the camera
@NotEdwinDev
@NotEdwinDev 5 жыл бұрын
Why does my code lock only able to type double numbers such as 11,22,33,44 and My passcode can get wrong everytime just because of this. How do I fix that?
@aeonicsoftworks6370
@aeonicsoftworks6370 5 жыл бұрын
I'm assuming you are making two calls to the set value. Make sure there is only one Controller on the main camera. Make sure the if statement at line 22 in the codelock class is the same as i have wrote. if neither of these solve your issue have a look through the controller class and make sure it is exactly the same as i wrote. Also check the entire SetValue() method in the codelock class. If these still do not fix it feel free to copy paste your code as a reply and ill look at it for you.
@2ksnakenoodles
@2ksnakenoodles 3 жыл бұрын
It may be because you have Input.GetButton() instead of getbuttondown
@Lune1858
@Lune1858 3 жыл бұрын
@@2ksnakenoodles This fixed it thanks man :)
@2ksnakenoodles
@2ksnakenoodles 3 жыл бұрын
@@Lune1858 No Worries :D good to see it worked
@mapmakerger3118
@mapmakerger3118 5 жыл бұрын
Wait why is all green If u watch this on a note9 and put the Video Quality on 720p48 its green
@EdwinCreatives
@EdwinCreatives 5 жыл бұрын
Phone problem or KZbin problem... Not the video's fault.😂😂😂
Better Coding in Unity With Just a Few Lines of Code
15:27
Firemind
Рет қаралды 316 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,2 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 17 МЛН
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 15 МЛН
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 51 МЛН
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 8 МЛН
Can You Charge A Phone with Marbles?
18:06
Engineezy
Рет қаралды 1,1 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 736 М.
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 6 МЛН
How are Redstone Computers even possible?
19:36
Ellie Rasmussen
Рет қаралды 351 М.
This tiny computer changes EVERYTHING
15:57
Jeff Geerling
Рет қаралды 726 М.
FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial
9:58
Dave / GameDevelopment
Рет қаралды 1,1 МЛН
How I learned Unity without following tutorials (Developing 1)
18:11
Game Maker's Toolkit
Рет қаралды 2,1 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 17 МЛН