- Home /
Unable to Attach to Player but Public Class and File Name Match
Just what it says up there. I even changed the class name and the file name in a new copy and it's still kicking it back to me. As you can see I've tried rewriting things from scratch, even loading the finished script from the tutorial I was following. All to no avail.
Thanks a ton in advance!
Update: I found some JavaScript code that should do the same thing my C# code does. I imported it to see if I could work around whatever's happening. Same error.
how did you bring this into unity to start, if you used click drag in windows file view unity will not except that, because it has a built in asset tracker, you must use its importer. or use your default editor to make it. by first choosing create new script.
I tried dragging it in, and I imported it with Asset importing, but more importantly I wrote the original script (FPS) after choosing New Script. Gave me the error message the first time, and every time after.
If you've had any errors in your code adding new files are unable to be placed on objects until they have been fixed. From the look of the screenshot this may be the case but it's not possible to see what that error is
Alright. Do you mean errors as in grammatical issues in presently attached code or something else. Do you mean it's not possible to see from the pictures, or that it's just not possible and I'll have to fumble around in the dark until I find it.
If it's the former, and I'm hoping it is, how do I find the error?
@DoctorWho Dragging in to the project in Windows Explorer works fine for me. In fact its the only method I use to update my FBX files, so as to avoid having to re-setup. Unity likes to make duplicates.
Answer by DoctorWho · Jul 10, 2014 at 02:24 AM
#pragma strict
var Bullet : Rigidbody;
function Update () {
// Ctrl was pressed, launch a projectile
if (Input.GetButtonDown("Fire1")) {
// Instantiate the projectile at the position and rotation of this transform
var clone : Rigidbody;
clone = Instantiate(Bullet, transform.position, transform.rotation);
// Give the cloned object an initial velocity along the current
// object's Z axis
clone.velocity = transform.TransformDirection (Vector3.forward * 10);
// destroys the object after a time
Destroy (clone.gameObject, 5);
}
}
you can still use the" (Input.Get$$anonymous$$ouseButtonDown(0));" ins$$anonymous$$d of if (Input.GetButtonDown("Fire1"))
let us know what you think if this salves it for you, and so on. that way we will know if it was code or something else messing up.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
WheelColliders Bug Fix 0 Answers
C# Script is affecting multiple GameObjects but I would like it to only affect one of them... 1 Answer
How To Make Enemy Chase You? 1 Answer
How would I go to add the Players Voice in the game? 2 Answers