Hello Everyone!
I am working on a side scrolling shooter and have a few questions. I have only been working with Unity for a few days and I am amazed at the number of helpful tutorials both on this site and on the web in general.
I am having trouble in a few areas. I am learning C# as I go and borrowing libraries of code with heavy examination to comprehend it. I am using a tutorial to get my feet wet and I am following it to the letter.
I set my background, which is 2 layers set to position Z 2 and Z 4 that will allow parallax scrolling (once I get there)
After that, I import my player sprite, set it to position 0,0,0, scale is 3, 2.5, 1 (just to get it to the right size.) I then create a Box Collider 2D component for it, then a Rigidbody 2D component for it. I reduce the gravity to 0 and check the Fixed Angle box. After saving the scene and hitting play, the sprite just falls down as if it has gravity, until it gets to the area below my background graphic and stops. If I check the “Is Trigger” box it does not fall. (this is not detailed in the tutorial. I was just messing around with the options and it worked).
With that done, I then load a script onto the player object that allows me to move the sprite around with the arrow keys.
Then I add my first enemy at position 0,5,0 adding the same components and options (which also gets shoved off of the play area unless I check “Is Trigger”) and add a script that just makes the enemy move to the left and off the screen view. The tutorial indicates that if the two sprites (which are on the same Z level) intersect, they will block each other (which makes since, because I haven’t defined any OnCollision behavior) but they just pass through each other.
What am I doing wrong? I can paste the scripts I am using here if that will help.
-
Why do the sprites keep flying off the play area when I hit play, unless I have the Is Trigger box checked? They seem to move rapidly towards whichever side of the play area they are closest to.
-
Are the sprites supposed to hit each other and stop? Or are they supposed to pass through each other if no OnCollision behavior has been defined?
I also have some questions about animating sprites, but I want to get the bones of the game in place before I start tackling that.