0

Is there any way to script projectiles in Unity2D using c# without the rigidbody gravity components automatically set in place by unity. I know it has something to do with transform/raycasts but I am new to programming and all tutorials on youtube are always only for Unity3D and not Unity2D. Please could any youtube videos be mentioned to lead me down the right path.

Watching Unity3D tutorials (since they were the only ones available) and simply converting components to Unity2D did not work.

derHugo
  • 83,094
  • 9
  • 75
  • 115
  • Is your question regarding Unity code in the UnityScript language or the C# language? Note that UnityScript has been deprecated in favour of C# since about 2017. – ProgrammingLlama Nov 13 '22 at 11:12

1 Answers1

0

The basic principles of most tutorials about 3D games will apply the same for 2D games. But there are often separate built-in methods for 2D things, such as collision detection, that are advisable to use, if only because they are less expensive computationally. There are, after all, only two axis to consider in 2D, instead of three.

Of course you could implement the mechanics yourself without relying on rigidbody components at all. Raycasts are, simply put, lines, drawn from one point to another inside the game world, and if they touch anything you'll get a notification and some information about what they touched.

Gravity is, in its simplest implementation, adding a value to whichever way is "down" in your coordinate system.

If you have a specific problem in mind where you wanted to convert from a tutorial that was meant for 3D to 2D but it didn't work, maybe link to the tutorial and post your code, so people can see what went wrong.