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 navadeep2011 · May 06, 2013 at 06:17 AM · scaleprojectiletranslateupdate functionthrow

How can i translate my object?

Hi All,

I am working on projectile motion. In that there is a button called throw. if i click throw button the ball object going projectile. In that i got maxheight. by using this code i am getting the height.

  string height = GUI.TextField(new Rect(Screen.width-85, 10, 75, 25), (maxHeight).ToString());
  if (maxHeight < (Projectile.transform.position.y - transform.position.y )){
      maxHeight = ( Projectile.transform.position.y - transform.position.y );    
      }


After got max height i have a scale. I below of the scale there is sphere type of object. I want to pass that object into max height point.

i mean if i got maxHeight = 6.5 then that sphere i want to movie vertically same height.

for that i wrote code.

 using UnityEngine;
 using System.Collections;

 public class Tran : MonoBehaviour {
 public GameObject game;
  void Start () {
 }
 void Update()
 {
  game.transform.Translate(game.transform.position.x,(game.transform.position.y+ThrowSimulation.maxHeight), game.transform.position.z);
 } 
 }


But it is showing error. after playing my application that is automatically came into scenemode. If i write the custom method also not working properly.

And my task is when ever the throw is complete. i want to show my maxheight by using that sphere in that scale. please help me

thanks in advance

Navadeep

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 moghes · May 06, 2013 at 06:48 AM 0
Share

you need to scale your sphere or translate? you can use transform.localScale for scaling

avatar image navadeep2011 · May 06, 2013 at 06:51 AM 0
Share

No.. no.. scale is just static object. i want to translate sphere(vertically) depending upon that max height.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sanky · May 06, 2013 at 06:53 AM

do you want to transform game object so you have to try this

public class Tran : MonoBehaviour { public Transform game; int treee; void Start () { } void Update() { game.transform.position=new Vector3(game.transform.position.x,game.transform.position.y+2,game.transform.position.z); } }

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 navadeep2011 · May 06, 2013 at 09:17 AM 0
Share

Sanky, Thanks for your help. the problem is that the sphere is not getting to rest at the particular height.

     using UnityEngine;
     using System.Collections;
     public class Tran : $$anonymous$$onoBehaviour {
     public GameObject game;
     void Update(){
     game.transform.position=new Vector3(game.transform.position.x,game.transform.position.y+ThrowSimulation.maxHeight,game.transform.position.z);
      }
      }


I wrote the code above. I want to stop at maxheight. but that is going.......

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

14 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

Related Questions

When I throw the projectile, it triggers the land collision before landing on it 0 Answers

Scale using accelerometer with limits 0 Answers

Scale using accelerometer with limits 0 Answers

The floating point origin and AI 1 Answer

VR Scale/Move 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