13
2013
Convert old project to 2D physics & Sprites
Started converting this shootemup test into Unity 4.3 2D physics ( old: http://unitycoder.com/blog/2013/09/27/shoot-em-up-proto-unity/ )
Webplayer: (using new 2D physics & sprites, no collider on player yet)
http://unitycoder.com/upload/demos/Shmup3_2D/
Some conversion notes so far:
SHMUP TO 2D SYSTEM
Lets test..
2D viewport Enabled!
Camera:
– Setup Camera for Pixel Perfect graphics: http://forum.unity3d.com/threads/210329-Unity-4-3-Tips-amp-Workarounds?p=1415249&viewfull=1#post1415249
Player:
– Rename old “PlayerShip1” to “PlayerShip1Old”, disable it
– Take player ship image, set its type to Sprite
– GameObject / Create other / Sprite
– Rename this gameobject as “PlayerShip1”
– Copy my playercontroller script component to this “PlayerShip1”
– Adjust speed (it was 255, now 3 is enough, since sprite is 1×1, instead of 64×64)
– Add 2 empty gameobjects as child, for GunPivot and LaserPivot, and position them
– Assign those pivots to playercontroller script variables
– Set gameobject Tag & Layer
– Create new prefab from “PlayerShip1” (drag it to project folder)
Player Bullets:
– Take our bullet image, set its type to Sprite (default settings as above)
– GameObject / Create other / Sprite
– Rename this gameobject as “SpriteBullet1”
– Copy my bulletcontroller script component to this “SpriteBullet1”
– Create prefab from this “SpriteBullet1”
– Assign that prefab to playercontroller as a bullet prefab
– ** something happened, sprite (image) is missing from the prefab **
– Lets assign the bullet image(sprite) to it again from assets
– Old bullet had box collider & rigidbody..
– So lets add BoxCollider2D and RigidBody2D
– Adjust BoxCollider2D size
– Set Rigidbody2D gravityscale to 0 (it was 1, and bullet was falling down..)
– Old bulled was moved with transform.Translate() inside Update(), remove that.
– So lets try just RigidBody2D.Velocity after instantiate, just add 1 line (and 1 speed variable)
clone.rigidbody2D.velocity = Vector2.right*bulletSpeed;
– Set bullet gameobject Tag & Layer
– Bullets are colliding to eachother..
– Need to set Project Settings / Physics2D / Layer Collision Matrix (I had set these for Physics also, for not allowing player bullet to player bullet collisions)
Enemy:
– Take our bullet image, set its type to Sprite (default settings as before)
– GameObject / Create other / Sprite
- Note: If you have that sprite already selected, it will be assigned to this sprite gameobject
– Rename this gameobject (sprite) as “Enemy1”
– Copy my enemycontroller script component to this “Enemy1”
– Old enemy had box collider and transform.Translate() movement
– Lets add BoxCollider2D
– Adjust BoxCollider2D size
– Set “Enemy1” gameobject Tag & Layer
– ** hmm bullets collide to enemy, but wont do any damage.. **
– Ok, had to replace this line in bulletcontroller:
void OnCollisionEnter(Collision collision)
with:
void OnCollisionEnter2D(Collision2D collision)
– Adjust explosion particle system size to smaller
…
Related Posts
12 Comments + Add Comment
Leave a comment
Recent posts
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
Creating a 2D game with Unity
http://pixelnest.io/tutorials/2d-game-unity/
2D tank game with physics:
http://www.unit3y.com/unity-2d-tank-game-part/
lots of 2D tutorials!
http://pixelnest.io/tutorials/2d-game-unity/table-of-contents/
2D Character collider tutorial live tomorrow:
http://unity3d.com/learn/live-training/session/2d-character-controllers
SpriteAnimator.cs:
http://pastebin.com/icV6tA64
2D issues and how to solve:
scripts/examples download (from that^ video)
https://dl.dropboxusercontent.com/u/6006520/GDC/Examples.zip
new talk similar topics:
2D Best Practices In Unity
^ Those talks are old, “ignore everything” said by unity:
http://forum.unity3d.com/threads/2d-game-graphics-for-different-resolutions.265627/#post-2215466
free 2D assets
https://www.assetstore.unity3d.com/en/#!/content/18684
interesting info, about box colliders getting stuck:
http://www.iforce2d.net/b2dtut/ghost-vertices
getting pixel perfect graphics:
http://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/