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 bitthebillias · Jan 23, 2019 at 08:13 PM · scripting probleminputcontrols

Clicking won't throw object

So when i am ingame, i can't get this object to be thrown, it just tells me that there is no input set up for it. I can pick it up because i added an input for that, but i don't understand how to edit the other button inputs to get them to work.

how do i get them to work properly?

Any thoughts will help! thanks!!

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class ThrowObject : MonoBehaviour
 {
 
     public Transform player;
     public Transform PlayerCam;
     public float throwForce = 10;
     bool hasPlayer = false;
     bool beingCarried = false;
     public AudioClip[] soundToPlay;
     private AudioSource audio;
     public int dmg;
     private bool touched = false;
 
     // Start is called before the first frame update
     void Start()
     {
         audio = GetComponent<AudioSource>();
     }
 
     // Update is called once per frame
     void Update()
     {
         float dist = Vector3.Distance(gameObject.transform.position, player.position);
         if (dist <= 2.5f)
         {
             hasPlayer = true;
         }
         else
         {
             hasPlayer = false;
         }
         if (hasPlayer && Input.GetButtonDown("Use"))
         {
             GetComponent<Rigidbody>().isKinematic = true;
             transform.parent = PlayerCam;
             beingCarried = true;
         }
         if (beingCarried)
         {
             if(touched)
             {
                 GetComponent<Rigidbody>().isKinematic = false;
                 transform.parent = null;
                 beingCarried = false;
                 touched = false;
             }
             if (Input.GetMouseButtonDown(0))
             {
                 GetComponent<Rigidbody>().isKinematic = false;
                 transform.parent = null;
                 beingCarried = false;
                 GetComponent<Rigidbody>().AddForce(PlayerCam.forward * throwForce);
                 RandomAudio();
             }
             else if (Input.GetMouseButtonDown(1))
             {
                 GetComponent<Rigidbody>().isKinematic = false;
                 transform.parent = null;
                 beingCarried = false;
             }
         }
     }
     void RandomAudio()
     {
         if (audio.isPlaying)
         {
             return;
         }
         audio.clip = soundToPlay[Random.Range(0, soundToPlay.Length)];
         audio.Play();
     }
     void OnTriggerEnter()
     {
         if (beingCarried)
         {
             touched = true;
         }
     }
 }
 
 

alt text

alt text

screen-shot-2019-01-23-at-31053-pm.png (27.9 kB)
screen-shot-2019-01-23-at-30717-pm.png (24.4 kB)
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

2 Replies

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

Answer by xxmariofer · Jan 23, 2019 at 08:19 PM

Hello, can you open one of those buttons tab? and share a screenshot? probably they have nothing set in the Positive Button property.

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

Answer by bitthebillias · Jan 23, 2019 at 10:05 PM

alt text

I think this is what you were talking about, if not please let me know!


screen-shot-2019-01-23-at-32338-pm.png (54.8 kB)
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 xxmariofer · Jan 23, 2019 at 10:23 PM 0
Share

Hello you need to assig a positive and or negative button, that will be the button that will fire the input, open the horizontal and vertical axis and check how they do have the positive and negative field assign with the buttons or keys that will fire the input.

avatar image bitthebillias xxmariofer · Jan 23, 2019 at 10:57 PM 0
Share

so i gave that a shot. the left click works now, but for whatever reason, the throw option doesn't seem to work. it just drops like the right click. thoughts?

avatar image xxmariofer bitthebillias · Jan 23, 2019 at 11:03 PM 0
Share

what do you mean by the throw option?

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

182 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 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 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 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 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 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 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 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 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

2D Platformer - Action When Key Is Pressed During Collision C# 0 Answers

Why does the keyboard control what button is selected? 2 Answers

ps3 controller messed up the normal controls 1 Answer

This is not possible to be called for standalone input. Please check your platform and code where this is called (C#) 2 Answers

What is the best way to watch for button/key presses? 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