Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 difd 9999 · Nov 21, 2012 at 04:11 PM · gamejava

scripting help needed, load level?

i am making a game and i am having scripting problems i want to make it so when var bullet is touching var self level 2 loads

var bullet : Transform;

var self : Transform;

self = transform.rotation;

transform.rotation = Quaternion.identity;

function update (){

if (self){ Application.LoadLevel(2); }

}

//please post a full script

Comment
Add comment · Show 1
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 GerryM · Nov 21, 2012 at 05:21 PM 1
Share

1) Please format your code!

2) Read up on OnCollision and use that to check for collisions

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Steve Steven · Nov 21, 2012 at 06:01 PM

I suggest you to use Raycast.

Raycast is physics sensor we can call which goes from an origin, to a direction for a length, which if not assigned is Mathf.Infinity.

This physics sensor stops when get collision with any collider. In this way you don't need to instantiate this bullet as Transform.

so your script for raycast will be:

 var origin : Vector3
 var direction : Vector3;
 var distance : float;
 var hit : RaycastHit;
 function ShootProjectile () {
     if (Physics.Raycast (origin, direction, distance, hit)) {
         //get collided
     } else {
         //no collision
     }
 }
 if (hit.tag == "Tag") {
     Application.LoadLevel (x);
 }

If you need for more in depth detail, remember to check the Scripting Reference by Unity3d about Physics.Raycast

Comment
Add comment · Show 2 · 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 difd 9999 · Nov 25, 2012 at 03:21 PM 0
Share

I got it up and runing without raycast but thanks for posting

avatar image Steve Steven · Dec 04, 2012 at 01:08 PM 0
Share

You are welcome

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

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Script in UNITY ??? 2 Answers

Bullet Fire script not working 1 Answer

How do i make an animation play on key press? 3 Answers

Convert this line of javascript to C# (easy) 1 Answer

i need some code suggestions 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