How to apply code formatting within your post

Code is frequently shared on the forum often by members of the community seeking an answer to a problem, or by members providing a solution to a problem. Providing consistent, easy to read code makes it easier for the person you are trying to help, or, for the people you are seeking help from.

Code formatting is essential for readability, please consider your community and take an extra moment to format your code in your post.

Applying code formatting;

  • On a new line, enter three ` characters

  • On the next line, paste / start writing your code

  • On a new line after your code, enter three ` characters

  • The preview pane displays how your code will look once posted

    With code formatting applied correctly, syntax highlighting will also be applied to your code, this further enhances the experience of the reader.

See also;

1 Like
[Help] The computer repeats the guessed number
NullReferenceException when using variable from other script
Loop Fail. Feel free to ROAST me
Getting multiple user inputs eventhough im pressing each key once
My first programing with logic plz check it once
Audio Behaviour is not the same as the video at the end of this lecture
[HELP] Lose Collider triggers on its own after some seconds
Not sure why I have an error
Rocket not subject to gravity?
[Help] Ridding Compiler Errors
Need help with C++
HELP! State Error C2039 'GetSessionInterface': is not a member of 'IOnlineSubsystem'
[QUESTION] Switch statements, and additional scripts/text boxes?
Can't find error
Options Not Working
Element 0
ERROR - An object reference is required to access non-static member
Saying that it can't use void on line 18 and 42
The local function is not declared cs8321 [SOLVED]
Lose collider GameObject script giving error
What does "this" indicate in the else part of MusicPlayer.cs
Can someone Help!
Program automatically displays "Space key pressed" on start up
Unable to correct vertical movement
PlayClipAtPoint in Unity 5
CameraRaycaster won't find enum Layer-tried multiple solutions already
VisualStudio 2017 will break if I use square brackets
Visual Studios 2017 and Unity 2017.2.0. Console not printing
Hi! i need a little help in the OnUserInpt function
Unity 5 updates
Inadvertently learned things!
How to move and animate projectiles
Bricks are not being destroyed
Problem with Number Wizard
[Help] Return Key is not responding
Parsing error
The referenced script on this Behaviour is missing!
Compiler Error Learn to Code by Making games
[Help] The Return Key doesn't display anything on the console
Defender instances keep trying to access destroyed attacker instances
Every time i push down it answers it twice
Destroy smoke after it's gone?
I dont understand the problem here
LoadNextLevel() method in Brick.cs is still red
Unexpected Symbol Void
Crack sound doesn't play when i hit the brick also boing sound plays everytime even when i hit the brick
Getting Error - Feature "Local functions" is not available in C# 4
Hover and click color did not change
[Solved] Game doesn't switch to Win Scene if player dies
this.GetComponent<Rigidbody2D>().velocity compiler error
Am i doing something wrong orrrrr?
I'm stuck here because there are some error
CS0117: 'Terminal' does not contain a definition for 'Writeline'
[Solved] Need Help with Script Error
Game works, but I'm still getting "Object reference not set to an instance of an object
Dungeonis demo so far!
NullReferenceExeption Error
Confused after audio.Play(); didn't work
Text doesn't update when State changes
Getting the error because velocity
Object Reference Error
Enemy Formation doesn't move anymore
Block breaker paddle movement seems a little stuck
Next Level Activates after first block is destroyed - Counting issue
[SOLVED] My background size is half of the size of background which Ben teaching and My paddle is not starting from the centre where I am pointing the mouse what changes I do in the code?
Inacessible due to protection level
Confusion as to why I get Array Index out of range if I initialise an array in a certain way
Cannot Get Zero to Block Numbers(With Codes)
Script messing with Paddle collision
Omg i did this
"Cannot implicitly convert type 'int' to ' string'"
Getting multiple errors for input key presses
Higher or Lower always changes the guess to 0
[Solved] Bricks stopped breaking
Spawn enemies one at a time at the start of the game
How to decrease the chance of a power-up occurring?
If statement inside if statement
Issues after "Fully Event Based Raycasting"
General Coding improvement query
Control Ball velocity Angle
[HELP] Object reference not set to an instance of the object
Change level after killing specified number of enemies
Type vs. Class Confusion
Understanding the code
Adding Pictures to the Text Adventure
[Help] Blurry ship movement?
S1L5 : A Simple DIY Follow Camera || NullReferenceException: Object reference
String instead of Int for level tracking?
Unity 2017.4.1f1 - Making a button that loads the next scene
Static Variables Cannot Be Used in Other Script
Random.Range - namespace clashes
Laser Defender Text error
[SOLVED] Methods driven by scene being run
SceneManager.LoadScene(1); trolls me
Resetting the ball to the paddle
[SUGGESTION] Naming Stuff
Help me guys
Unexpected behaviour from script
Fox jump trigger not triggering
[Solved] Error for unknown reason after changing Freedom to Corridor_0
[SOLVED] ; Up arrow not responding to key press
How to move and animate projectiles
Character will not stop moving
How does this code work. I don't get the foreach loop
Can not Take Parameters Error
Not able to make new line in Visual studio 2017 using Windows
States doesn't show in inspector
Issues with getting my code to refactor
State option not showing up
buttonArray is looking all the buttons
I need Help!
The programm runs fine in the Unity editor but doesnt work after build & run
Problem about scripting Diy_Follow_Camera in 2018.2.7f1 Version Unity
Changing the volume of an audio source
Projectile is not going to the player
Problem about scripting Diy_Follow_Camera in 2018.2.7f1 Version Unity
Understanding the SpawnUntilFull() function
I have a problem with the else command(SOLVED)
(solved) i coppied the code in this lecture exactly and have double checked. still reciving errors
How to this if else work
[SOLVED] AllMembersDead parsing errors?
Missing reference exception: the object of type 'transform' has been destroyed.. error in unity
Using variables- getting a compiler error
Character Generator / Virtual Tabletop Assistant
NullReferenceException: Object reference not set to an instance of an object
IndexOutOfRange- Script does not work
Number Wizard UI bug
Interesting situation (Solved)
[Solved] Enemy Formation Keeps moving Left
A couple of issues with pinsetter code
Explosio Partlcles play in beginning
Ball Launching continue when I click mouse
Ball/Brick Collisions Counts as Two Hits
I keep getting this error each time I try adding the LevelManager?
Sound Effects Either Don't Play or Are Muffled Extremely
Missing reference exception: the object of type 'transform' has been destroyed.. error in unity
Problem with showing unknown (?) Cursor
I stucked ForeGround invisible when i move on the ground
"string" does not contain definition for 'Anagram', how to fix?
Error CS8025: Parsing error
The Next Screen Text Won't Show Up!
Particle Effect
Loop back to start fail?
Object reference not set to an instance of the object
Code added to script is not executing at runtime
Code added to script is not executing at runtime
Added limited tries but how to prevent further input?
Am I doing something wrong?
Text101 - Simple Text Adventure
Finding Objects in Script
Error CS0201
Audio Clips don't play
My terminal hacker. 3 levels, login screen, and easter egg. Did I do this block quote right?
I still don't know how to save progress with PlayerPrefs
I still don't know how to save progress with PlayerPrefs
[Solved] No overload for method Quit' takes 1 argument
Help please
Laser Defender - Number of Enemies appears to be tied to Number of Waypoints
[Solved] Five Different Compiler errors
Start method dont call
Sound is played before the ball launched
[Solved] Simulate Destroy brick doesn't work
Alternative to one Defender per Square
MonoDevelop changes text into Text [SOLVED]
Keyword 'void' cannot be used in this context
If you can not extract method - here is a solution!
Where is OnUserInput() Defined
No audio on Ball using Array
Block Breaker errors within web browser
Creating New Method @ 1:14
Bullet is not moving forward
Showing off a scrolling background I created :)
Getting continual errors - any help would be great
Zombie Animation Bug
About 'Colliders, Collision & Triggers'!
Raycast not working for overlaying objects?
Is either of these two ways of handling audio better?
Says .Length doesn't exist
Climb Ladder - 'myCollider2D' does not exist
NullReferenceException:Object reference not set to an instance
(Solved) What is this and how can i solve it? Assets\AdventureGame.cs(9,28):
State and linking issue
I can't run my WebGL build
Delay time of death
Protecting against NaN - is this wrong?
What do you think?
About 'Public Methods & Return Types'!
I got a question on the way you could write your program with your own functions
Script not working
Trouble getting TextArea attributes working
Defender Prefab is not instantiate at clicked position in CoreGameArea
Serialized field "Score" not updating in the inspector
CoRoutine type
Null Reference Exception
InvokeRepeating for enemy ships
Null Refrence exception in Text 101
My first Lines of code Ever! + My Easter egg!
Why my enemy inflicts his own health even when it is not attacked by player
How to Salve INPUT so i can use it on other Function?
Back button is not working
About 'Manage Next States'!
Won't show Terminal.WriteLine on 2nd Win Screen
Getting an error
Why guess=min; and min=guess; arent same?
Would still like other peoples ideas to enhance my game
Scene Loader problem
My code did not work during the challenge and I am looking for an explanation why
Good stuff, done in about 5 mins
layerHit always returns as enemy
Implementing "DontDestroyObjectOnLoad" preventing blocks from being destroyed?
How do I display maxGuessesAllowed on the Canvas?
I want to pass desired position of the rock but it is not working?
Another little problem with my railshooter script
Cant assign clip to break object like what you did in the lecture 63
Question about code functions
Null Reference
OnTriggerEnter / OnColliderEnter is not working
Project Rocket Boost problem
OPERATION: Find The Error
Switch statements
I'm getting these 2 errors
Problems with Rotate and Thrust in code
Problem with GetStartingState();
[HELP]Please resolve this error
Unity2D Player movement
How would you write a forloop for letters rather than numbers?
Laser Defender need help with building resolution
Odd behaviour in playing death & success sounds
Anagram problem
Waypoint waypoint in waypoints
Issues with getting my code to refactor
"Game Over" scene not loading
`Terminal' does not contain a definition for `ClearScreen'?
No MusicPlayer Found while Saving Volume
Terminal Hacker Error -- Resolved
Using data from other scripts
Question about SetWaveConfig
Neat WinScreen
Really frustrating problem where Inspector doesn't seem to lock properly
Load next scene Problem
Array error
Struggling over here
The block collapses a second or two after hitting the ball with it
Problem in enemySpawner.cs
A Few Questions
Need a little help
Error nextStates
Particle Problems
Help with implementing distance-based damage
Lose Collider triggering for no reason
Why do we put something into the parenthesesof the ShowMainMenu method?
Question about C#
Particle systems are still not working
Bricks not updating sprites, but they do break after 1/2/3 hits
Getting null reference exception tried many things but nothing worked :(
I got a big error!
Don't know what I am doing wrong
Therminal Hacker Error
Spawning Meteors at random locations and setting appropriate velocity
Need help with the music manager
Nothing Shows Up In Console When I Run The Game
Unity gives me NullReferenceException: Object reference not set to an instance of an object... why?
Different approach for player movement. Which one is better?
Once the ball hits the paddle the game ends?
About 'Unity Scriptable Objects'!
First Solo Challenge
NullReferenceException: Object reference not set to an instance of an object PlayerController.Die ()
Error: The variable deathFX of Enemy has not been assigned
1st curly brackets "{" jumping one line when i copy-paste code
Local Greeting Challenge
Levels not loading
Enemies and Friendlies shooting at each other but nobody disappears
Audio somehow seems to be messing with my thrust or performance
Parameter 'jumpTrigger' does not exist
Having Trouble with greeting
Only the start button loads the success scene but the core game scene and the win scene buttons do not work
My last state wont display the text in the UI!
CS1519: unexpected symbol
It isn't hitting?
Can't find unexpected symbol in music player script
waveConfigs[startingWave] problem
Trying to create Health Counter with Images instead of Text
Observer Pattern
Alpha1 Input Issue
Problem with the nullreferenceEception: Object reference not set to an instance of an object
The name does not exist in the current context
NullReferenceException: Object reference not set to an instance of an object
Time Between Waves
Load Next Scene Problem
About 'Loop All Enemy Waves'!
[SOLVED] - The Mathf.Clamp function doesn't set my boundaries correctly
I edited the Hierarchy just as shown on the video, errors are still there, why?
Unity errors
I am almost there!
audio.Source.Stop(); giving me errors
Definition missing
Tons of errors
New type of enemy bug
About 'Add & Display Score'!
I have a error and the loop is not working
Getting a weird error
'State' does not contain a definition for 'GetStateStory'
Why parentheses?
Getting a Null Reference Exception Error - nothing works!
"GAME OVER" scene not loading
Type `State` is not recognised?
Terminal Hacker: if statement
Sharing my text as per instruction
Must Fix all compiler errors
Touch Input not working correctly
About Ball Following The Paddle
The collided settings in lecture 100 do not work on my emeny ships how to fix?
"GameOver" scene refuses to load after player dies
About 'Manage Next States'!
Ball don't stick to paddle but keeps bouncing
This is Hard. Someone please help!
My "if else" condition doesn't works, I can still press all of them same time and the message's showing up too
Expected a ')' in Atomic.h?
Please Help.. Error CS0246
Quick Fix using Range
Stuck with an error
Change scene not working
Problem with getting the code to run: " An object reference is required for the non-static field, method or property 'State.GetStateStory()' "
Can you give provide feedback/insight on the gameplay of my game Portal Reign?
Number Wizard - Greetings in Dominican Style
I can't go to Next Level
Access different rigidbody2D
First For Loop
Bool not changing
Run into an Error
Enemies not moving
Clamping the player with different code than you used in your example
Keep getting walkable although I am pointing on enemies
Playing and stopping rocket audio
What does "[SerializeField]" do and why is it in those square brackets?
What does "Vector2" do and why is it in not called Vector1 e.g.?
What is wrong here?why isn't it working?
Unity Hangs when I enter the password
Inconsistent line endings
About Terminal Hacker problem
Minor re-fueling visual problem (Bens rocket game on the 3d course)
I Cannot get What is the Problem here. My particle System is not Working
Moved my game reset; now trying to further my understanding on nullerror
Question about States
Can't come back to menu screen
Error on my enemy destroyed
Pls help there is error in my password section
How to give player an option to start the game on their own?
Unity 2017.4.1f1 - Making a button that loads the next scene
Velocity Tweak question
Don't Destroy on Load not Working
Higher and lower buttons not showing updated guessText value
Help with Attacker newAttacker
Please correct me
Unity Tower Defence: isPlacable bug
Paddle going to minX position of paddle
Waves not able to load WaveConfig
Please help, I don't know what to do
NumberWizard script issue?
How do I offset the Particle System relative to Ship
Mine doesn't display either Level or Current Screen
Glitch Garden "level win" sound repeats
Laser Defender! problems with WaveSpawner
In visual studio..a red line appears under the code even if it is true code
Particle Effect sometimes not working or is weak
Laser Defender! problems with WaveSpawner
Not destroying music player
Can't acces my public method from other class
Unable to get particles to trigger
Foreach statement won't work on lecture 132
Question in the Spit & Polish lecture of Section 3: Project Boost
Particle (Lighting) Bug when using "Maximize On Play"
Help with coroutine
Problems with the jet particles
Void CheckPassword issue
Waypoint Progress Tracker.cs / Error
I don't understand functions and start game
NullReferenceException EnemyPathing.Move()
Score not adding up, enemy not dying and giving null reference error
Weird problem with sprite character
Shield status issue
Failed attempt at implementing "range" in this shooter script
Projectiles dont give damage
Solve this Error
[Tilevania] Question on tutorial 145 0
It wont print
Lesson 140: How to keep cubes snapping with Cube Editor, but remove waypoint?
Problem in Grid movement
Failed attempt at implementing "range" in this shooter script
Problem in Grid movement