Search
Setup for Free
C
C#
Collision Error
Original message was deleted
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,156
Members
View on Discord
Similar Threads
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
C
cccc
•
10/22/22, 9:25 PM
line 40
=
public void OnCollisionEnter
(Collision other
)
{
if
(other
.gameObject
.tag
=
=
"Player
"
)
{
Debug
.Log
(
"HIT
"
)
;
playerController
.takeDamage
(15f
)
;
}
}
P
pip
•
10/22/22, 9:33 PM
this means that your GetComponent in your Start
(
) didn
't fire
. playerController is null
P
pip
•
10/22/22, 9:33 PM
Make sure the component you listed is attached to the object using this script
!
P
pip
Make sure the component you listed is attached to the object using this script!
C
cccc
•
10/22/22, 9:36 PM
playerController
= GetComponent
<ControllerTest2
>
(
)
;
C
cccc
•
10/22/22, 9:37 PM
doesnt that fetch it without having to assign it manually
C
cccc
•
10/22/22, 9:37 PM
since im using this within a prefab
P
pip
•
10/22/22, 9:37 PM
is ControllerTest2 assigned to your object in the editor
?
P
pip
•
10/22/22, 9:38 PM
it doesn
't automatically create it
P
pip
•
10/22/22, 9:38 PM
I think AddComponent adds it iirc
C
cccc
•
10/22/22, 9:44 PM
the problem is
C
cccc
•
10/22/22, 9:44 PM
i cannot assign it within the editor
C
cccc
•
10/22/22, 9:44 PM
because its a prefab that currently isnt spawned and wont spawn until called
, unity doesnt let me assign it unfortunately
C
cccc
•
10/22/22, 9:45 PM
so ill have to call the script through the script
C
cccc
•
10/22/22, 9:47 PM
FIXED WITH
:
playerController
= GameObject
.FindObjectOfType
<ControllerTest2
>
(
)
;
Similar Threads
collision help
C
C# / help
2y ago
✅ Hash collision checkin
C
C# / help
4mo ago
✅ Collision in Avalonia
C
C# / help
8mo ago