Hi I am working on some C# code in Visual Studio 2022 and am getting the following CS0246 error. It seems the SpritePos type cannot be found. I am using Unity3D (2.0.1) and Unit3D.SDK (2021.1.1.4.1). Can someone help determine why I’m getting this error and how to resolve it? Thx.
,Hi, I am working on some C# code in Visual Studio 2022 and am getting the following error. Please help determine why I am getting this error. I am using Unity3D (2.0.1), and Unity3D.SDK (2021.1.1.14.1) Thx!
GetComponent searches through a GameObject, looking for a component of the type that you put in the angled brackets. So, you would typically look for RigidBody or Animator or a named script (because any added scripts are components, just like the built-in components that Unity provides.
You got hold of hit.transform (which is both the transform and the GameObject) so that’ s OK for searching components but there is no component of type SpritePos - unless you created a script called that. If you have a script called SpritePos with a public field called pos then this would work.
You need to have a think about what it is that you’re trying to do. You can get hold of hit.transform.position, if that’s what you need. If, however, your sprite is in an array and you’re trying to find its location then this is not going to work.