generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: ROBLOX's Vector2 X and Y properties are readonly?

Previous Thread :: Next Thread 
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
14 Dec 2016 02:28 PM
http://wiki.roblox.com/index.php?title=Vector2#X

Why is this?


Y is a vowel in about the same way that France historically is a republic.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
14 Dec 2016 02:31 PM
Because there's a lot that could go wrong if it weren't.

Here's a snippet from Stravant which explains it really clearly:
"Because, it's impossible to make an API that works with it otherwise unless you're working in a language like C++ with a type-system that tracks const-ness.

Considering the following situation:
local a # #}##for i = 1, 100000 do
a[i] = somePart.Position
end

The possible outcomes:
1) A contains 100000 references to the same Vector3 object, that is the internal Vector3 representing the position of the part. That part can now change position without warning from anywhere in your project, without you knowing why it happened, because someone somewhere accidentally changed the value of a Vector3. You can see how that might be frustrating. Also, this requires having the part listening for changes on that Vector3 object to know when to update because the Vector3 changed.

2) A contains 100000 references to different Vector3 objects, that are copies of the position at the time. This is moderately better than the prior situation, but you can still modify any of these Vector3s from anywhere in the project and have it change elsewhere without warning. Also, it's confusing because now the part is no longer moved by editing it's position's components, which is probably why you wanted the mutability feature in the first place."
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
14 Dec 2016 02:48 PM
i'm probably just too used to using a vector2 class/module while using love2D and being able to change the x and y values


Y is a vowel in about the same way that France historically is a republic.
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
14 Dec 2016 10:56 PM
You can still write to Y only:

Vec2 = Vector2.new(Vec2.x, 5)

Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
14 Dec 2016 11:35 PM
Thats setting a vector, not writing to it.

You can't do this:

Vec2.x,Vec2.y = 5,5


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image