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 /
This question was closed Jul 22, 2014 at 03:35 PM by JusticeAShearing for the following reason:

I have no need for this information any more.

avatar image
0
Question by JusticeAShearing · Jul 10, 2014 at 03:45 PM · collisiondamageweaponrange

How Can One Collider Recognize Contact With Another?

I paint trees onto the landscape that have colliders, and am finding too much trouble with scripts that spawn trees as gameobjects (therefore the trees can have chopping scripts attached). I do have a question on that if you have an idea, though!

Another solution, which I don't have but am working on, is the script applied to the axe (or character) that recognizes if it is within range of a tree or collider, and destroys said tree/collider when a key is pressed. I would be very grateful if anybody who has an idea could post a comment, and anybody who has an answer could post an answer.

I have code here that may make the more basic parts require less thinking, so that if you are kind enough to try to answer, you will put your energy to more efficient use. I would be highly grateful for any help or reasonable effort at help.

 //Finding A Key (Backspace)
 
 if(Input.GetKeyUp(KeyCode.Backspace))
 {
 //Anything within these brackets is activated upon backspace
 }

This script is my original script. It is what needs to be changed somewhere. I think that it is in the Update function when it defines new variables.

 #pragma strict
 
 /*
 This script is currently applied to the tree in question
 
 This script must be applied to the character or axe
 It must recognise that it is hitting a tree via the tree's collider and then cut the tree down
 One cannot depend on the tree to do anything that is hasn't yet done. It must all work with the character or axe
 The character must have a detection of range so that it finds the tree, not the other way around
 It must have a timer to cut down the tree after a certain amount of time
 The animation is for later, but may be incorporated into this script
 */
 
 var chopDistance = 5;
 var inRange = false;
 var chopTime = 0;
 
 function Start () {
 
 }
 
 function Update ()
 {
     //This must be changed to find the tree, not the character
     var player : Vector3 = gameObject.Find("Character").transform.position;
     //This must be edited to look for the tree, not the player
     var moveDirection : Vector3 = player - transform.position;
     
     if (moveDirection.magnitude < chopDistance)
     {
         inRange = true;
     }
     
     if (inRange == true)
     {
         //This keycode must be changed to the LMB
         if(Input.GetKeyUp(KeyCode.Backspace))
         {
             Timer();
         }
     }
 }
 
 //This function seems to need not a single edition
 function Timer()
 {
     yield WaitForSeconds(chopTime);
     Destroy(gameObject);
     Player_Inventory.Players_Wood += 1;
 }
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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Ai that applies damage in collision? 1 Answer

Editing a variable from another script on collision 3 Answers

Damage on collision with player.. 1 Answer

Area of effect melee attack for 3rd person game? 1 Answer

PLease Help 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