• 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 Player4 · Aug 19, 2013 at 08:56 PM · positionfreezeclickonmouse

freeze position on click

I need help making my trampolines freeze after i click a cube. how my game works is theres two portals the start and end portal and your goal is to bounce a ball from one portal (the start portal) to the next (end portal) by bouncing it off of trampolines but my point is the trampolines are going to be lined up to where you want it then you click the cue releasing the ball but people could just guide the ball to the end portal so my goal is to make the trampolines freeze when they click the cube i've started a script already though that hasn't been working out can you please give me my problem and a solution or a different script to work.

here's the script:

 var cube : Transform;
  
 function OnMouseDown()
 {
     transform.Translate (500,500,500);
 }
 
 function OnMouseUp()
 {
 cube.MovePoint2.enable = false;
 }
   

 
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 bam191 · Aug 19, 2013 at 09:06 PM

What you want is:

 function Update()
 {
 
     if(Input.GetMouseButtonDown("0")){
         //code for trampolines to stop moving
         //this if statement is only triggered when the user clicks the mouse 0 button (left click by default)
     }
 }

That code will check if the player is pressing the mouse button, and you can make it freeze the trampolines simply by stopping their movement.

Comment
Add comment · Show 7 · 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 Player4 · Aug 19, 2013 at 09:35 PM 0
Share

but how do i stop movement by script

avatar image bam191 · Aug 19, 2013 at 09:38 PM 0
Share

Do you have a script that moves the trampolines?

avatar image Player4 · Aug 19, 2013 at 09:39 PM 0
Share

And i forgot to mention i have a drag and drop script that lets people move the trampolines seperetaly.

this is the drag and drop script:

private var screenPoint: Vector3; private var offset: Vector3; private var curScreenPoint : Vector3; private var curPosition : Vector3;

function Start () { }

function Update () { }

function On$$anonymous$$ouseDown () { screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position); offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)); Screen.showCursor = false; }

function On$$anonymous$$ouseDrag() { curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z); curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset; transform.position = curPosition; }

function On$$anonymous$$ouseUp(){ Screen.showCursor = true; }

avatar image bam191 · Aug 19, 2013 at 09:43 PM 0
Share

So wait, are the trampolines moving by themselves?

avatar image Player4 · Aug 19, 2013 at 10:23 PM 0
Share

no you drag them to set up the course so the ball bounces off them and i want it so that once you release the ball you can move the trampolines anymore

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

16 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

Related Questions

Freeze rigidbody position without affecting rotation - please help! 1 Answer

Frreze Rotation and poSITION PROBLEM HELP!! 2 Answers

So here is some really complicated question. 1 Answer

Freeze transform.rotation.x 1 Answer

Getting to move object with mouse position? 0 Answers


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