Unity Community |
Yay I finished Lab 01 - please check it out and play it here ... Bird BLASTER!!
Tell me what you think :P
Thank ProfCWalker for free resources![]()
Here's the blog post for my 2D Mario clone: http://lordherman.wordpress.com/2012...d-mario-clone/
Now on to the last lab!
Hi Guys,
I hope to get through the tutorials for mario 2d in two more weeks to start my own game. Otherwise my wife is going to divorce me for doing this day in day out and not getting a paying job! ; )
I'm on video #40 part 18 - 1 block breakable of mario 2d scroller, and I have a dumb question. How is that in this tutorial we are writing the block breakable script yet the blocks ALREADY have been breakable before this? I'm confused. I suppose this question only applies to the geometry breakable as the particles breakable calls the physics 'particle emitter' component (i think).
PN99
OK, I found a work around, but it still doesn't work perfectly.These videos are fantastic. Thanks Walker brothers for making such high quality tutorials!
I am currently doing the 2D Mario tutorial, and I've hit a problem I can't find a solution for. On tutorial 23-11 "gumba pathnode," after writing this code in the enemyGumba script:
which is supposed to link to the pathNode script, Unity gives me this error:Code:
{ { gumbaState = linkToPathNode.pathInstruction; } }
Assets/2D Mario Assets/Scripts/enemyGumba.js(116,69): BCE0022: Cannot convert 'PathInstruction' to 'GumbaState'.
I've looked over the script several times, and it's exactly the same as the code in the video, but I get an error. Later in the tutorial a similar error occurs, but a workaround is found that fixes it. Any ideas from anyone why I'm getting this error?
I've "finished" the lab, but there is a problem with either the ChangePlayerState function in the colliderAttackBox script, or the SetPlayerState function in the playerProperties script. I've triple or maybe even quadruple checked the code, and I don't see any problems with it, but when Mario hits a gumba, there's some confusion with the states. It seems that the MarioDead case is being called every time, even when Mario is big and should just change to small and not die. I've spent a lot of time playing around with the code trying to come up with a solution, but haven't had any luck. Anyone else having problems with this?
I'd like to make a suggestion to the Walker brothers, and that is please include the completed scripts with the downloadable assets. There are a few very annoying things that happen when you don't include them. For example, every time I want to check my code I need 1) an internet connection, 2) to let the videos load (which can take a long time depending on the length of the video and speed of the connection), and 3) scanning the video for the right part that shows the code I want to check. I've spent A LOT of time doing the above to try and find what is wrong with my code, and so far I can't find anything. Also, unlike the other labs, you do not actually have a video that only shows the code. So, I've spent a few hours every day for about three weeks working through the 2D Mario tutorial, and now I'm "finished" and don't even have a playable game because of problems with the code that I can't identify, and I don't have anything to check it against...it's a bit frustrating.
Last edited by dayunbao; 03-07-2012 at 12:47 AM.
I am wrapping up the 2D mario clone now. Moving on the 3D one. You guys are Super Heroes to the Unity beginner and Amateur programmer. Looking forward to whatever you do next. I will soon post link to showcase what you have taught me. Thanks for everything!!
These videos are fantastic. Thanks Walker brothers for making such high quality tutorials!
I am currently doing the 2D Mario tutorial, and I've hit a problem I can't find a solution for. On tutorial 23-11 "gumba pathnode," after writing this code in the enemyGumba script:
function OnTriggerEnter (other : Collider)
{
if(other.tag == "pathNode")
{
var linkToPathNode = other.GetComponent(pathNode);
gumbaState = linkToPathNode.pathInstruction;
}
}
which is supposed to link to the pathNode script, Unity gives me this error:
Assets/2D Mario Assets/Scripts/enemyGumba.js(116,69): BCE0022: Cannot convert 'PathInstruction' to 'GumbaState'.
I've looked over the script several times, and it's exactly the same as the code in the video, but I get an error. Later in the tutorial a similar error occurs, but a workaround is found that fixes it. Any ideas from anyone why I'm getting this error?
OK, I found a work around, but it still doesn't work perfectly.
I've "finished" the lab, but there is a problem with either the ChangePlayerState function in the colliderAttackBox script, or the SetPlayerState function in the playerProperties script. I've triple or maybe even quadruple checked the code, and I don't see any problems with it, but when Mario hits a gumba, there's some confusion with the states. It seems that the MarioDead case is being called every time, even when Mario is big and should just change to small and not die. I've spent a lot of time playing around with the code trying to come up with a solution, but haven't had any luck. Anyone else having problems with this?
I had that exact same problem, after searching around I found this bit of code:
if(other.tag == "pathNode")
{
var linkToPathnode = other.GetComponent(pathNode); //get pathNode.js
gumbaState = parseInt(linkToPathnode.pathInstruction);
}
"The parseInt() function parses a string and returns an integer" which just means it takes your enum text, and reads it numerically... Which I think it was supposed to do anyway... why it only sometimes works is beyond me.
This problem drove me NUTS, but it was a simple fix.
When this will be available?
http://walkerboystudio.com/html/unit..._template.html
I ran into a slight problem in the fifth lab (the 3D Mario clone). Some parts of the project use Unity Pro functionality, and so make error messages appear in the free edition. I've moved the offending assets out of the project folder for the time being, and removed references to them (which only appeared to be on the main camera object). Is that the right way to handle this sort of issue, or will it cause problems later on?
For reference, the assets causing trouble were in these folders:
Assets/Standard Assets/Image Effects (Pro Only)
Assets/Standard Assets/Water (Pro Only)
Assets/Standard Assets/Editor/Image Effects
Assets/Standard Assets/Editor/Water (Pro Only)
great tutorial but the sound is soooo low, even full blast :/
Will the 2D Mario Clone tutorial work with UniTile and 2D Toolkit?
Haven't done the full tutorial yet,but this by far the most complete VTC you can find on the net. Thanks a lot for this.
I am working on the Lab 1, and I am on the Homework part of it, and not sure where to go with the 3 Count and the Flashing of the Sphere. If some one can give me a few hints that would be great.
Wow, great course we have here.
I'm already doing lab01, and I have some "problems" with the explosions.
I'm actually using Unity 3.5, and I've already looked into "Legacy Particles", although I've done to do the explosions via the actual way, due to the fact that when I loaded the emitter, renderer and animator from "Legacy Particles", the particles just rendered as purple cubes, instead of glowing particles.
Also, doing it with the new particle system, I'm having some problems while trying to adjust the size of the explosion, as it doesn't work if I just try to scale it.
I've looking every option, and the best I got is a condensed explosion via "Limit velocity over Lifetime", although it's not quite exactly what I'm looking for.
Another current issue, is that when I set the game on "Play Mode" and destroy an enemy, an object called "prefabExplosion(Clone)" just creates into my Hierarchy tab, so if I destroy, let's say, 20 enemies, then 20 prefabExplosion(Clone) objects are created.
My question is: Do these consume actual memory? Is there any way to actually make these disappear as soon as it's animation is end?
By the way, when I pause and play the game again, they just disappear (to be created again, as soon as I destroy any enemy).
Thanks a lot for the future help provided
PS: Just checking the explosions video, I see a clone is created and just deleted after it's done, so yeah, it can be made. Let's see if I'm able to figure out how to do it.
Last edited by Miyavi; 03-11-2012 at 06:45 PM.
Hi Miyavi
I've written a blog post here >>http://www.unity-projects.co.uk/shur...system-lab-01/
which shows the code to destroy each particle as it finishes playing through its animation
the code to add to your particle is this
function Update ()
{
if (!particleSystem.IsAlive()) Destroy (gameObject);
}
Also with the Legacy system the reason you've got purple cubes insted of the default particle material is that you need to select it in the particle renderer
hope this helps
Last edited by ChrisAllen; 06-10-2012 at 08:44 AM.
Thanks for that Chris.
My new code for auto-destruct particles is as it follows:
However, I get a compiler error whenever I try to run it.if (!particleSystem.IsAlive()){
Destroy (explosion);
}
If I'm instantiating an object called "explosion", shouldn't that be the one to be destroyed too?NullReferenceException: Object reference not set to an instance of an object
UnityEngine.ParticleSystem.IsAlive (Boolean withChildren) (at C:/BuildAgent/work/b0bcff80449a48aa/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:400)
UnityEngine.ParticleSystem.IsAlive () (at C:/BuildAgent/work/b0bcff80449a48aa/Runtime/ExportGenerated/Editor/ParticleSystemBindings.cs:393)
scriptEnemy.Update () (at Assets/scriptEnemy.js:36)
I'm kinda missed here.
you need to input the code exactly as I've shown, into a new script, which you attach to the explosion prefab
you don't need to substitute gameObject for the name of your explosion object. As long as the script is attached to the explosion prefab it will work with "gameObject" (as it relates to the current gameObject the script is attached to)
Last edited by ChrisAllen; 03-12-2012 at 05:53 AM.
Superb!
It's working now.
Thanks a lot for that.
Edit:
_______________
Back with another doubt.
I want to get access to scriptPlayer.js from scriptScreenWin.js to show the final score when the time is over.
I'm doing the following.
The compiler keeps telling me the following error:var playerScore = GetComponent(scriptPlayer);
UI.Label(Rect(10,10,100,40), "Total Score:" + playerScore.score);
Where am I wrong?NullReferenceException: Object reference not set to an instance of an object
EDIT2:
_______________
Oh whell, just looking for some information...
I just achieved what I wanted by setting the "score" variable as a static one, and then getting access to it from win.js as scriptPlayer.score.
Is this the only way to do this?
I mean, I think I just got confused by this code
That code is part of playerScript, and it's getting access to a scriptEnemy variable.var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition); //get mouse position
if (Physics.Raycast(ray, hit, rayDistance)){
if(hit.transform.tag == tagName){
//var position = Vector3(Random.Range(-6,6), Random.Range(-4,4), 0); //new random position for the GO
//hit.transform.position = position; //move the GO to the new location
var enemyScript = hit.transform.GetComponent(scriptEnemy);
enemyScript.numberOfClicks -= 1;
if(enemyScript.numberOfClicks == 0){
score += enemyScript.enemyPoints; //TO-DO: Change score based on shape.
}
} else {
print ("You didn't hit an enemy");
}
}
Doh! We really need a CODE tag in the forums >.<
Last edited by Miyavi; 03-12-2012 at 12:02 PM.
great catch ianismrt. Holy, if it weren't for that snippit and your post, i'd be possibly stuck forever (as is usually the newbie) : ).
THanks.
ps. don't forget the 'Node' in 'linkToPathNode' is cap N.
Miyavi, you can set a game object to not be destroyed on level load using the following.
Object.DontDestroyOnLoad(myGameObject);
you'll have to research it more as i've never used it