Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mangohack · Sep 25, 2011 at 02:39 AM · error

scripting error

hi everyone i trying to my character shoot fireball but i got htis error

NullReferenceException: Object reference not set to an instance of an object this is my script

var speed : float = 3.0; var rotateSpeed : float = 3.0; var bullitPrefab: Transform;

function Update () { var controller : CharacterController = GetComponent(CharacterController);

// Rotate around y - axis transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);

// Move forward / backward var forward : Vector3 = transform.TransformDirection(Vector3.forward); var curSpeed : float = speed Input.GetAxis ("Vertical"); controller.SimpleMove(forward curSpeed);

if(Input.GetButtonDown("Jump")) { var bullit = Instantiate(bullitPrefab, GameObject.Find("SpawnPoint").Transfrom.position,Quaternion.identity);

} } @script RequireComponent(CharacterController)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by aldonaletto · Sep 25, 2011 at 03:12 AM

There's a problem in this instruction:

 Instantiate(bullitPrefab,GameObject.Find("SpawnPoint").Transfrom.position,...

There's no Transfrom component - it's .transform.position:

 Instantiate(bullitPrefab,GameObject.Find("SpawnPoint").transform.position,...

Notice that transform must be in lower case, since it's a game object variable. Additionally, make sure that an empty object named "SpawnPoint" exists (that's where the bullets will be instantiated).

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image timberland8989 · Sep 25, 2011 at 03:34 AM 0
Share

Thanks for co$$anonymous$$g our timberland online store! Just enjoy yourself here! As a developping company, timberland boots always can give us some surprise .I belive timberland shoes Sale can make your feet more comfortable, make your life more stylish!If you want to have a try ,just click here: discount timberland boots Free delivery

timberland

timberland boot

timberland shops

timberland 2011

discount timberland

wholesale timberland

timberland chaussures

avatar image timberland8989 · Sep 25, 2011 at 03:34 AM 0
Share
avatar image mangohack · Sep 25, 2011 at 06:37 AM 0
Share

thanzx i fixed it but now my question is how can i make my fireball move

avatar image aldonaletto · Sep 25, 2011 at 01:50 PM 0
Share

The best way is to set the rigidbody velocity. You can use the transform.forward vector, what will shoot the bullet horizontally in the direction the player is turned to:

 // shoot the bullet at 10m/s 
 bullit.rigidbody.velocity = transform.forward * 10;

A better alternative is to use the camera forward direction, so you can control the elevation angle you're shooting - substitute transform.forward by Camera.main.transform.forward

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Getting a bunch of errors after the latest Unity update (Unity 3.8f1) 5 Answers

How to solve this error related to facebook SDK ... its complicated 1 Answer

Global Error Logging and Overflow Checking? 3 Answers

Object reference not set to an instance of an object - Unity FPS Sample 1 Answer

Animation Error "unexspected token "if" 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges