Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » FREE Project Downloads & Recources » Scripts » Scale Geometry With your Keyboard [By BryceCain25]

Scale Geometry With your Keyboard [By BryceCain25]

View previous topic View next topic Go down  Message [Page 1 of 1]


In this script, it demonstrates how you can scale geometry when a trigger is activated and you are pressing right or left arrow key..the multiplier variable allows you to scale in ratios..

var MultiplierZ : int;
var ObjectToScale : GameObject;
var MultiplierY : int;
var MultiplierX : int;

//Created By BryceCain25
//the following script is an example and can be used in any project
// ^ remove the following above when pasting in your code
//Rememeber! this is for learning to :P

function OnTriggerEnter () {
if(Input.GetKeyDown(KeyCode.RightArrow)) {
ObjectToScale.transform.localScale += new Vector3(MultiplierZ*1F, 0, 0); //scale the figure On the Z Axis By
//multiplying Multipler * 1, Vector3 just means we are working with a 3D Object instead of Vector 2
//which would be 2D Figures
//use this example to create the rest of the code, make sure that you are using the right Multiplier :)

The // comments allow you to learn a little bit more than copy and paste. Make sure you remember that the two zeros after "MultiplierZ*1F" are integers that use the Z, Y, and X axis. Use a different "IF" statement for each line of code
1) Use a Collider with the "Trigger" boolean checked off
2) Attach script to object with collider trigger
3) Use player input, as soon as you enter the collider you use <-- --> (Left and Right Arrows) to scale, well, depending on how you coded it from the example.
We are all here to learn, so this is a good way to practice! Very Happy

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum