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 /
This question was closed Aug 23, 2016 at 05:39 PM by Funnyman1120 for the following reason:

Found the solution

avatar image
0
Question by Funnyman1120 · Aug 22, 2016 at 05:07 AM · unity 5sizecubeplane

Scaling a cube side by a plane length

So I'm in school learning how to code and make games etc, and I'm trying to work on a small personal project via Unity. So basically I started setting up some basics of a game with some 3D rooms, nothing fancy, going to be top down 2.5D.

So I decided if I could make a room prefab that would make my life a lot easier. So I put down a plane, and made several cubes a child of the plane, then manually scale the to the correct positions.

So then I wanted the walls to move and scale with the plane to be at the correct locations and be the correct length and width. So I wrote this script, which right now mainly scales the cube's width to always be the same no matter what the scale of the plane is.

 using UnityEngine;
 using System.Collections;
 
 [ExecuteInEditMode]
 public class Resizing : MonoBehaviour {
 
     [SerializeField]
     Transform Floor;
     [SerializeField]
     int X1Y2;
 
     // Use this for initialization
     void Start () {
     
     }
 
     // Update is called once per frame
     void Update () {
         float X1Scaling = 10.3f - ((Floor.localScale.z - 1) * 0.1f); //z
         float Y2Scaling = 10.3f - ((Floor.localScale.x - 1) * 0.1f); //x
         if (X1Y2==1)
             transform.localScale = new Vector3(0.3f/Floor.localScale.x,transform.localScale.y, X1Scaling); //z
         if (X1Y2 == 2)
             transform.localScale = new Vector3(0.3f / Floor.localScale.z, transform.localScale.y, Y2Scaling); //x
     }
 }
 

So now I want to make it so the length of the cubes are always meeting up at the ends, and when the scale of a side of the plane is at 1, the correct scale for a cube is 10.3. So I tried several different things to make this work, but it is always slightly under or overscaled. (See below).

So I was wondering if anyone had a good idea on how I can scale this properly?

Floor scale of 1 alt text

Floor scale of 12 alt text

1.jpg (161.7 kB)
2.jpg (107.6 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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Dimensions of a Cube 2 Answers

What is the difference between these, and how do I fix it. 2 Answers

Best Image Formats, Sizes, and Resolutions for Unity Sprites? 2 Answers

max size of a cube at irregular angles 2 Answers

Resizing Unity terrain without resolution 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