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 dione001 · Oct 21, 2013 at 12:36 PM · drop

Drop item into a certain/fixed position

What i wanted to do is to drop an object into a certain/fixed position. Can anyone help me with my problem,What would I do to solve my problem?.

Thanks in Advance guys.

Comment
Add comment · Show 2
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 meat5000 ♦ · Oct 21, 2013 at 12:38 PM 0
Share

Have you had a go at it and done a bit of googling? Or written some code?

avatar image Natrx · Aug 24, 2020 at 10:27 PM 0
Share

how did u fix it??

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by logicandchaos · Aug 26, 2020 at 12:31 AM

you set the objects transform.position

Comment
Add comment · Show 1 · 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 Natrx · Aug 27, 2020 at 03:20 PM 0
Share

By the way do you know if you can help me with my problem. I want to find the last item that used a specific code then instantiate it, This is a drop item system for my stickman game. So Heres the Code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Scene$$anonymous$$anagement; using UnityEngine.UI;

public class Itempickup : $$anonymous$$onoBehaviour { public GameObject Item; bool playerContact; public Transform Feet; public bool equippedOn; public GameObject ThisItem; public Layer$$anonymous$$ask Weapons; public GameObject LastItem; public GameObject This; public GameObject It; [SerializeField] private Text text;

 public void Start()
 {
      text.gameObject.SetActive(false);
 }

 private void OnTriggerEnter2D(Collider2D collision){   
     if(collision.CompareTag("Pickup")){
    playerContact = true;  

     text.gameObject.SetActive(true); 
         }
     
 }

 void OnTriggerExit2D(Collider2D collision)

{ if (collision.CompareTag("Pickup")) playerContact = false; text.gameObject.SetActive(false);

}

private void Update(){ if (playerContact == true && Input.GetKeyDown(KeyCode.E)) {
GameObject[] ThisItem = GameObject.FindGameObjectsWithTag ("Weapons");

     foreach(GameObject go in ThisItem)
     {
         go.SetActive(false);
         Spawn();
         
     }

       
        Equip();
        

        
       

        
             
               
             
      }

      if(Input.GetKeyDown(KeyCode.G))
      {
          ThisItem.SetActive(true);
          Item.SetActive(false);
      }


      

}

 void Equip()

{

    Item.SetActive(true); 

    //ThisItem.SetActive(false);
    Destroy(gameObject);
    equippedOn = true;
    
    

}

void Spawn() {

     Instantiate(ThisItem, transform.position, Quaternion.identity);
     Debug.Log("Prefab $$anonymous$$ade" + ThisItem.name);
     
  

}

void Drop() { It.SetActive(false); This.SetActive(true); equippedOn = false;

} }

By the way im a beginner coder so there is probably a faster way

avatar image
0

Answer by Llama_w_2Ls · Aug 27, 2020 at 03:52 PM

You can attach an event system component onto the object you want to drag and run public functions whilst being dragged and whilst being dropped. You can set the objects transform.position to the Input.mousePosition;

Comment
Add comment · 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

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

19 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

Related Questions

Picking up a box 2 Answers

Drag Drop Inventory With GUI Buttons. 0 Answers

Networking 5.1 drops framerate 0 Answers

Item pickup and drop function 2 Answers

Parenting 1 object/Removing child/ pick up 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