@@GameCodeLibrary Sure, here it is. PlayerMove is similar to your Player Tag: Boulder is not defined. UnityEngine.StackTraceUtility:ExtractStackTrace () PlayerMove:OnCollisionEnter2D (UnityEngine.Collision2D) (at Assets/Scripts/PlayerMove.cs:150)
@jazioxmugen looks like you need to create the tag “Boulder” on your object! In the inspector there’s a drop down at the top to add tags. It gives this error when that tag doesn’t exist
@@GameCodeLibrary I have the tag set as "Boulder" though. That's where I am getting confused. I checked the spelling and everything but for some reason, the error still shows. The boulders hit the platforms and get destroyed and my player doesn't get destroyed as well. This is my code private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Boulder")) { Destroy(this.gameObject); } }
@jazioxmugen that is strange!!! Unity can break sometimes in weird ways, perhaps try closing down your project then reopening and seeing if it’ll work 🧐
Heyy at 6:00 i am getting an error in the console tab saying "Trying to invoke method: Objectfallcontr.Fall couldnt be called the game is runiing bit the object is not falling from up
Make sure your capitalization is correct when calling methods to invoke. This is how the script should be: using System.Collections; using System.Collections.Generic; using UnityEngine; public class ObjectFallController : MonoBehaviour { float wait = 0.1f; public GameObject fallingObject; // Start is called before the first frame update void Start() { InvokeRepeating("Fall", wait, wait); } void Fall() { Instantiate(fallingObject, new Vector3(Random.Range(-10, 10), 10, 0), Quaternion.identity); } }
@@GameCodeLibrary i wrote the same exact code but its not working still using System.Collections; using System.Collections.Generic; using UnityEngine; public class ObjectFallController : MonoBehaviour { float wait = 0.1f; public GameObject fallingObject; // Start is called before the first frame update void Start() { InvokeRepeating("Fall", wait, wait); } void fall() { Instantiate(fallingObject, new Vector3(Random.Range(-10, 10), 10, 0), Quaternion.identity); } }
The capitalization is wrong on your function: In InvokeRepeating("Fall", wait, wait); it's capital F Your void fall() is lowercase f Make them the same and it'll work! :-)
Thanks it worked, i wanted to ask you if i wanted to. Make the game for android or ios what should i write in the player controller code so. It can move right or left
heyy!! i am having an error on 4:42 where you are adding the ObjectFallController script tag to the main camera i copied all the steps but when i am adding the script to main camera its showing "cant add the script component because the script cant be found and there is no errors in the script too
Double check the name of the script within the script compared to the name of the script file in Unity! If they're different it doesn't work and can give this error :-) Hope this helps!
@Unknown-wx6td have you made the falling objects prefabs by dragging them from the hierarchy to the folder? Then delete the one in the hierarchy and use the prefab in your script slot.
@@Unknown-wx6td That's strange!! I can only suggest checking through the video again at the part of creating the objects - since I can't see your project to help out! Hope you can find the problem 🙏
Hi and thank you for the tutorial. I'm just starting with Unity after using scratch for over 2 years - I'm 10 🙂 I'm trying to work through your tutorial but think maybe my system is not right. When I go to add the the script 'PlayerController' yours says in the top left hand corner Assembly-CSharp. Mine says Miscellaneous Files (with a icon that says C#). When I enter your code some things are not highlighted in blue (MonoBehaviour as an example) could it be that when I create the script, that I somehow need to make sure that it opens with a screen that says Assembly-CSharp? If so, can you please advise? Appreciate any help :-)
Hi! I have another video which should hopefully fix the problem you're having! th-cam.com/video/WWmFZGKaLII/w-d-xo.html Try following these steps and seeing if your scripts work now!
I am at 10:00 and when I try play the game it tells me "The type or namespace name 'Action' could not me found (are you missing a using directive or an assembly reference?)" I have used this code alongside a different player movement script I got from a different video I found before this, could it be something tied to that? P.S. I am very new to C# and Unity, so if it something obvious, that would be why :). Great tutorial by the way
If there are no red underlines in your code, then check the name of your scripts compared to what they’re called inside! At the top, before the monobehavior bit, that’s the name of your namespace. That name has to match the name of your actual script file, otherwise Unity can’t find it.
Hello, instead of making it game over, my game is about 3 aestroids with 3 point deduction, so 1 aestroid deducts 10 points the other 20 etc. my total points is 100, if the player collides with the aestroid is it possible to deduct score and there is also a timer. how can i do that?
When we set the player to call the PlayerDied() action, instead deduct your points here - on collision. (Around 8:20 in the video!) Then when your points are 0 you can call the game over screen! I have another video on adding in a timer and showing the game over screen on timer end as well, you can check that out here: th-cam.com/video/T0atxxGoOlE/w-d-xo.html Good luck!
I have a video coming out on Friday where I add a player health with three hearts to our platformer game, but you can use the same method I do there for this crab game as well!! 😊 But you’ll basically want a variable for the crabs health that decreases when hit. Then only call game over when the health variable is at 0! 🙏
Thank you so much, I’ve been searching everywhere for similar game ideas, yours hits the closest to what I wanna make!!
I’m glad I could help!! I’ll try do some more one vid mini games in the future - they’re fun!
Great video !! 🦀
Thank you! 🦀❤️
At 6:00, my game throws an "Object is not defined" error even though I followed what you did. Can you help explain why that this?
Could you send me the error it’s giving you?
@@GameCodeLibrary Sure, here it is. PlayerMove is similar to your Player
Tag: Boulder is not defined.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
PlayerMove:OnCollisionEnter2D (UnityEngine.Collision2D) (at Assets/Scripts/PlayerMove.cs:150)
@jazioxmugen looks like you need to create the tag “Boulder” on your object! In the inspector there’s a drop down at the top to add tags. It gives this error when that tag doesn’t exist
@@GameCodeLibrary I have the tag set as "Boulder" though. That's where I am getting confused. I checked the spelling and everything but for some reason, the error still shows. The boulders hit the platforms and get destroyed and my player doesn't get destroyed as well. This is my code
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Boulder"))
{
Destroy(this.gameObject);
}
}
@jazioxmugen that is strange!!! Unity can break sometimes in weird ways, perhaps try closing down your project then reopening and seeing if it’ll work 🧐
Thank you very much, this is extremely helpful
Glad you enjoyed! 🙏
Thank you very much for the valuable informations
You’re welcome!! I hope I can keep making videos that’ll help you in the future 🙏
Amazing video!!
I'm glad you enjoyed!! :-)
Heyy at 6:00 i am getting an error in the console tab saying "Trying to invoke method: Objectfallcontr.Fall couldnt be called the game is runiing bit the object is not falling from up
Make sure your capitalization is correct when calling methods to invoke.
This is how the script should be:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectFallController : MonoBehaviour
{
float wait = 0.1f;
public GameObject fallingObject;
// Start is called before the first frame update
void Start()
{
InvokeRepeating("Fall", wait, wait);
}
void Fall()
{
Instantiate(fallingObject, new Vector3(Random.Range(-10, 10), 10, 0), Quaternion.identity);
}
}
@@GameCodeLibrary i wrote the same exact code but its not working still
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectFallController : MonoBehaviour
{
float wait = 0.1f;
public GameObject fallingObject;
// Start is called before the first frame update
void Start()
{
InvokeRepeating("Fall", wait, wait);
}
void fall()
{
Instantiate(fallingObject, new Vector3(Random.Range(-10, 10), 10, 0), Quaternion.identity);
}
}
The capitalization is wrong on your function:
In InvokeRepeating("Fall", wait, wait);
it's capital F
Your void fall()
is lowercase f
Make them the same and it'll work! :-)
Thanks it worked, i wanted to ask you if i wanted to. Make the game for android or ios what should i write in the player controller code so. It can move right or left
@@magnificientcars9769 You'll have to look up a tutorial for that since it depends on how you want to move 👍 Good luck
Hello, Thank you for this tutorial
You're welcome I'm glad you enjoyed it!! I'll do some more making games in one vid sometime - they're fun :-)
❤ ur videos they help so much !! xx
I’m so glad they help you!! I’ll keep making more so we can keep learning together 😌🙏
heyy!! i am having an error on 4:42 where you are adding the ObjectFallController script tag to the main camera i copied all the steps but when i am adding the script to main camera its showing "cant add the script component because the script cant be found and there is no errors in the script too
Double check the name of the script within the script compared to the name of the script file in Unity! If they're different it doesn't work and can give this error :-)
Hope this helps!
@@GameCodeLibrary thank you it worked but only one floating object is falling not multiple floating objects
@Unknown-wx6td have you made the falling objects prefabs by dragging them from the hierarchy to the folder? Then delete the one in the hierarchy and use the prefab in your script slot.
@@GameCodeLibrary when i did that not a single object is falling
@@Unknown-wx6td That's strange!! I can only suggest checking through the video again at the part of creating the objects - since I can't see your project to help out!
Hope you can find the problem 🙏
Every time I run this, my game crashes. Can you explain why?
Nevermind, I figured it out! I added the script to my prefab when I should have just added it to the camera
Hi and thank you for the tutorial. I'm just starting with Unity after using scratch for over 2 years - I'm 10 🙂
I'm trying to work through your tutorial but think maybe my system is not right.
When I go to add the the script 'PlayerController' yours says in the top left hand corner Assembly-CSharp. Mine says Miscellaneous Files (with a icon that says C#).
When I enter your code some things are not highlighted in blue (MonoBehaviour as an example) could it be that when I create the script, that I somehow need to make sure that it opens with a screen that says Assembly-CSharp?
If so, can you please advise?
Appreciate any help :-)
Hi!
I have another video which should hopefully fix the problem you're having!
th-cam.com/video/WWmFZGKaLII/w-d-xo.html
Try following these steps and seeing if your scripts work now!
Nice video!
Glad you enjoyed it!
I am at 10:00 and when I try play the game it tells me "The type or namespace name 'Action' could not me found (are you missing a using directive or an assembly reference?)"
I have used this code alongside a different player movement script I got from a different video I found before this, could it be something tied to that?
P.S. I am very new to C# and Unity, so if it something obvious, that would be why :). Great tutorial by the way
If there are no red underlines in your code, then check the name of your scripts compared to what they’re called inside!
At the top, before the monobehavior bit, that’s the name of your namespace.
That name has to match the name of your actual script file, otherwise Unity can’t find it.
Hello, instead of making it game over, my game is about 3 aestroids with 3 point deduction, so 1 aestroid deducts 10 points the other 20 etc. my total points is 100, if the player collides with the aestroid is it possible to deduct score and there is also a timer. how can i do that?
When we set the player to call the PlayerDied() action, instead deduct your points here - on collision. (Around 8:20 in the video!)
Then when your points are 0 you can call the game over screen!
I have another video on adding in a timer and showing the game over screen on timer end as well, you can check that out here:
th-cam.com/video/T0atxxGoOlE/w-d-xo.html
Good luck!
Why am i floating when i used the falling thing
I need help
I don’t know!! Can’t see any of your code lol if you follow every step in the vid it’ll work 🙏 promise! There must be a little mistake somewhere!
By any chance can you point me into the right direction where the crab has three lives?😅
I have a video coming out on Friday where I add a player health with three hearts to our platformer game, but you can use the same method I do there for this crab game as well!! 😊
But you’ll basically want a variable for the crabs health that decreases when hit. Then only call game over when the health variable is at 0! 🙏
@@GameCodeLibrary you are my favorite TH-camr thank you so very much
You’re welcome and thank you I’m glad you enjoy my vids!!! I’ll keep trying to make simple and fun tutorials 🙏