Jump to content

Unity 3D


Recommended Posts

So, I have a question:

In Unity 3D, how do I move an object? Not slowly, just immediately teleport it to a position?

Edit: can someone move this back, it's a completely non-KSP related question, just programing in general.

Edit2: it is C#, but I do know some Java, so I'll be able to understand that too.

Edited by TechnicalK3rbal
Link to comment
Share on other sites

Assets/Camera_Script.cs(13,27): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position'. Consider storing the value in a temporary variable

This is the error I get.

If it'll help.

Edit: this is the code:

transform.position.x = sphereController.sphereLocation.x;

sphereLocation is the (It is a public Vector3) location of an object in the game that I want the camera to follow.

Link to comment
Share on other sites

Have you tried:

transform.position = Vector3(sphereController.sphereLocation.x, transform.position.y, transform.position.z);

?

Also, are you sure you're accessing the right transform? The compiler may think you want something like the PartModule's transform rather than the GameObject's. So also try stuff like

this.transform.position.x

or

gameObject.transform.position.x //Note that gameObject here is lowercase as it's a member variable rather than a class name.

Link to comment
Share on other sites

Edit: now I'm getting this error.

Internal compiler error. See the console log for more information. output was:

Unhandled Exception: System.UnauthorizedAccessException: Access to the path "C:\Users\(name)\Desktop\Games (Mine!)\Game 1\Temp\Assembly-CSharp.dll.mdb" is denied.

at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0

at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean isAsync, Boolean anonymous) [0x00000] in <filename unknown>:0

at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access) [0x00000] in <filename unknown>:0

at Mono.CompilerServices.SymbolWriter.MonoSymbolWriter.WriteSymbolFile (Guid guid) [0x00000] in <filename unknown>:0

at Mono.CSharp.SymbolWriter+SymbolWriterImpl.WriteSymbolFile () [0x00000] in <filename unknown>:0

at Mono.CSharp.SymbolWriter.WriteSymbolFile () [0x00000] in <filename unknown>:0

at Mono.CSharp.CodeGen.Save (System.String name, Boolean saveDebugInfo, Mono.CSharp.Report Report) [0x00000] in <filename unknown>:0

at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0

at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0

Edited by TechnicalK3rbal
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...