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 mihir solanki · May 10, 2015 at 06:49 PM · transformpositionscalecylinderside

scale a cylinder from one side only

alt text

i have a cylinder shaped like a rod as in the pic which i need to scale from only on of its side .i tried adding half of its increased scale to its position but i am not able to achieve it.i just need to increase its size lengthwise from one side and cancel increase from the other .i am using the current logic but it does not work:-

 function Update()
 {
  if(Input.GetButtonDown("Fire1"))
  {
     transform.localScale.y+=1;
     transform.position.x = transform.position.y + transform.localScale.y/2;
     }
     }

please help!

cylinder.jpg (66.2 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
0

Answer by Cherno · May 10, 2015 at 08:07 PM

initialLength is just the actual length of of cylinder, and transform.forward might have to be substituted with another direction depending on the cylinder's pivot orientation.

 var initialLength : int = 2;
 var currentLength : int = 2;
 
 function Update() {
 
 transform.localScale.y+=1;
 currentLength += 1;
 
 transform.position = transform.position + transform.forward * ((currentLength - 1) / 2);
 }
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 mihir solanki · May 12, 2015 at 02:18 PM 0
Share

nope ur code is malfunctioning and sending it zoo$$anonymous$$g upwards with high position change

avatar image
0

Answer by nieyoub23 · Nov 08, 2017 at 05:13 PM

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class fluidScale : MonoBehaviour {
 
     /*Changing the scale of the z axis while changing the position along the z axis,
      * giving the visual effect that the fluid is moving in one direction. Doing it
      * this way because Unity scales in two directions, not one.*/
 
     public GameObject FluSph;
 
     //I used 0,0,0.5 
     public Vector3 ExpandZ;
 
     //0,0,0.25
     public Vector3 MoveZ;
     
     // Update is called once per frame
     void Update () {
 
         //makes the cube scale bigger on the Z axis
         FluSph.transform.localScale += ExpandZ;
 
         //transforms the position of the cube to make it appear that it is only expanding on one side
         FluSph.transform.position+=MoveZ;
     }
 }
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

[solved] Get upward orientation of object and add scale value 1 Answer

postion scale and rotation greyed out and not working 1 Answer

Transform shows local scale instead of just scale 1 Answer

GUI item with object position+dimensions 0 Answers

How is transform.position affected by scaling? 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