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 NhommeBeurreOne · Jan 22, 2012 at 08:48 PM · javascriptdestruction

Simple Fracture ( Destruction )

Hello Guys,

I founded that script on the net : Simple Fracture and it suppose to create Destructible Environment. I apply it on a Cube that I flatten out and tag as "Target". And I put these lines of code in my Shoot Script :

 if ( Hit.rigidbody.gameObject.CompareTag("Target")) {
         SimpleFracture.FractureAtPoint( point : Vector3, force : Vector3);
     }

The problem is that I get these errors.

For those of you who know how to use it maybe help with this question : Does the fracture script go on the object I want fracturing, and the call fracture in the same script?

Best Regards,
NbO

Source

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 Lo0NuhtiK · Jan 22, 2012 at 10:02 PM

the function "FractureAtPoint" is to recieve a (point : Vector3) and (force : Vector3) when you call it.
Send it the information you want to send, not weird parameters or whatever---- point : Vector3 being the hit area, and force : Vector3 being the force you want to add.

Example :

 var forceToFracture : Vector3 ; //set in inspector
  
          if(Hit.rigidbody.gameObject.CompareTag("Target")){
             SimpleFracture.FractureAtPoint(Hit.point , forceToFracture) ;
          }

I'm assuming you're raycast-shooting... idk.. anyway Hit.point would be whatever contact-point vector3 you're hitting stuff at.

Comment
Add comment · Show 6 · 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 NhommeBeurreOne · Jan 22, 2012 at 10:18 PM 0
Share

Hello, I tried what you said and I get this error now :

Assets/Scripts/Shoot.js(236,28): BCE0020: An instance of type 'SimpleFracture' is required to access non static member 'FractureAtPoint'.

Any Idea ?

avatar image Lo0NuhtiK · Jan 22, 2012 at 10:33 PM 0
Share

I'm guessing you never assigned your SimpleFracture script in this script, and you're trying to access it directly by name. If that isn't the case, then idk.


    var fracScript : SimpleFracture ;
     
    function Start(){
       fracScript = gameObject.GetComponent(SimpleFracture) as SimpleFracture ;
    }

then in your if statement ->
fracScript.FractureAtPoint(Hit.point, forceToFracture) ;



EDIT :

just thought that the fracture script is probably on the hit object, so here's another guess since I don't really know where your scripts are and all that stuff.

put this in your if statement if this is the case.


     if(whatever){
     var frac : SimpleFracture ;
//!!EDITED--> add "collider" to the next line, that should work
     frac = Hit.collider.gameObject.GetComponent(SimpleFracture) as SimpleFracture ;
     frac.FractureAtPoint(Hit.point , forceToFracture) ;
     }
avatar image NhommeBeurreOne · Jan 23, 2012 at 10:21 PM 0
Share

In your edit you're wright, but it still didn't work. I edit my post to give a link to the source : http://forum.unity3d.com/threads/57994-Simple-Fracture-Script-v-1.01 .

NbO

EDIT: I get this error :

$$anonymous$$issingFieldException: Field 'UnityEngine.RaycastHit.gameObject' not found. Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.FindExtension (IEnumerable`1 candidates) [...]

avatar image Lo0NuhtiK · Jan 23, 2012 at 10:30 PM 0
Share

I added an edit in the code above here.
Not having "collider" on that line gives an error about 'gameobject' not being a member of 'raycasthit' ; so that's a different error than the one you posted...
If changing that line doesn't help, then idk... do some troubleshooting on your end since all the scripts and objects are on that side lol

avatar image Pr3Z · Feb 17, 2012 at 04:43 AM 0
Share

how did you get it working in 3.5??

Show more comments

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

6 People are following this question.

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

Related Questions

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Faux Gravity Prolem? #2 2 Answers

How to find a prefab in another scene? 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