How to implement axis dragging in unityHow do I calculate someone's age in C#?How do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I generate a random int number?What is a NullReferenceException, and how do I fix it?Raytracing in Unity error C#Unity's Transform.Translate moves on z axis when translating on xHow to change a parent class variable from child class in unity

Why are prop blades not shaped like household fan blades?

What would the United Kingdom's "optimal" Brexit deal look like?

Is it okay for me to decline a project on ethical grounds?

Why are we moving in circles with a tandem kayak?

Why did some Apollo missions carry a grenade launcher?

"DDoouubbllee ssppeeaakk!!"

How to efficiently shred a lot of cabbage?

Is Ear Protection Necessary For General Aviation Airplanes?

Can living where Earth magnetic ore is abundant provide any protection?

Typesetting numbers above, below, left, and right of a symbol

PCB design using code instead of clicking a mouse?

What is my clock telling me to do?

Rampant sharing of authorship among colleagues in the name of "collaboration". Is not taking part in it a death knell for a future in academia?

Unknown indication below upper stave

Just how much information should you share with a former client?

Is it possible to tell if a child will turn into a Hag?

Why did I lose on time with 3 pawns vs Knight. Shouldn't it be a draw?

Why would an invisible personal shield be necessary?

Spider-Man and Fantastic 4 crossover comic with Double Identity Scene

Why would anyone ever invest in a cash-only etf?

Are all French verb conjugation tenses and moods practical and efficient?

Raindrops in Python

Is it unprofessional to mention your cover letter and resume are best viewed in Chrome?

Embedded C - Most elegant way to insert a delay



How to implement axis dragging in unity


How do I calculate someone's age in C#?How do you give a C# Auto-Property a default value?How do I enumerate an enum in C#?How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I generate a random int number?What is a NullReferenceException, and how do I fix it?Raytracing in Unity error C#Unity's Transform.Translate moves on z axis when translating on xHow to change a parent class variable from child class in unity






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I've been trying to implement a move tool similar to the one built into the unity editor. After failing to make it I've spent many hours trying to find a way to do it. I came up with this:



Plane groundPlane = new Plane(Vector3.up, Tracked.position);
Plane rightPlane = new Plane(Vector3.right, Tracked.position);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
switch (axis)

case Axis.X:
if (groundPlane.Raycast(ray, out ent))

float deltaPosX = ray.GetPoint(ent).x - lastHitPos.x;
Tracked.position = new Vector3(Tracked.position.x + deltaPosX, Tracked.position.y, Tracked.position.z);
lastHitPos = ray.GetPoint(ent);

break;
case Axis.Y:
if (rightPlane.Raycast(ray, out ent))

float deltaPosY = ray.GetPoint(ent).y - lastHitPos.y;
Tracked.position = new Vector3(Tracked.position.x, Tracked.position.y + deltaPosY, Tracked.position.z);
lastHitPos = ray.GetPoint(ent);

break;
case Axis.Z:
if (groundPlane.Raycast(ray, out ent))

float deltaPosZ = ray.GetPoint(ent).z - lastHitPos.z;
Tracked.position = new Vector3(Tracked.position.x, Tracked.position.y, Tracked.position.z + deltaPosZ);
lastHitPos = ray.GetPoint(ent);

break;



Fixed links!
Unity Editor: https://youtu.be/I0DAVa7GIeo

What I currently have: https://youtu.be/cTykv-KTNOY










share|improve this question


























  • Looks good! What was the question?

    – Zock77
    Mar 26 at 22:56











  • I've messed up the links. Unity is under what I currently have.

    – Pitr _
    Mar 27 at 5:28











  • You may need to add an offset to the postion depending on where you clicked the arrow. That would keep it from jumping around like that.

    – Zock77
    Mar 27 at 15:29

















1















I've been trying to implement a move tool similar to the one built into the unity editor. After failing to make it I've spent many hours trying to find a way to do it. I came up with this:



Plane groundPlane = new Plane(Vector3.up, Tracked.position);
Plane rightPlane = new Plane(Vector3.right, Tracked.position);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
switch (axis)

case Axis.X:
if (groundPlane.Raycast(ray, out ent))

float deltaPosX = ray.GetPoint(ent).x - lastHitPos.x;
Tracked.position = new Vector3(Tracked.position.x + deltaPosX, Tracked.position.y, Tracked.position.z);
lastHitPos = ray.GetPoint(ent);

break;
case Axis.Y:
if (rightPlane.Raycast(ray, out ent))

float deltaPosY = ray.GetPoint(ent).y - lastHitPos.y;
Tracked.position = new Vector3(Tracked.position.x, Tracked.position.y + deltaPosY, Tracked.position.z);
lastHitPos = ray.GetPoint(ent);

break;
case Axis.Z:
if (groundPlane.Raycast(ray, out ent))

float deltaPosZ = ray.GetPoint(ent).z - lastHitPos.z;
Tracked.position = new Vector3(Tracked.position.x, Tracked.position.y, Tracked.position.z + deltaPosZ);
lastHitPos = ray.GetPoint(ent);

break;



Fixed links!
Unity Editor: https://youtu.be/I0DAVa7GIeo

What I currently have: https://youtu.be/cTykv-KTNOY










share|improve this question


























  • Looks good! What was the question?

    – Zock77
    Mar 26 at 22:56











  • I've messed up the links. Unity is under what I currently have.

    – Pitr _
    Mar 27 at 5:28











  • You may need to add an offset to the postion depending on where you clicked the arrow. That would keep it from jumping around like that.

    – Zock77
    Mar 27 at 15:29













1












1








1








I've been trying to implement a move tool similar to the one built into the unity editor. After failing to make it I've spent many hours trying to find a way to do it. I came up with this:



Plane groundPlane = new Plane(Vector3.up, Tracked.position);
Plane rightPlane = new Plane(Vector3.right, Tracked.position);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
switch (axis)

case Axis.X:
if (groundPlane.Raycast(ray, out ent))

float deltaPosX = ray.GetPoint(ent).x - lastHitPos.x;
Tracked.position = new Vector3(Tracked.position.x + deltaPosX, Tracked.position.y, Tracked.position.z);
lastHitPos = ray.GetPoint(ent);

break;
case Axis.Y:
if (rightPlane.Raycast(ray, out ent))

float deltaPosY = ray.GetPoint(ent).y - lastHitPos.y;
Tracked.position = new Vector3(Tracked.position.x, Tracked.position.y + deltaPosY, Tracked.position.z);
lastHitPos = ray.GetPoint(ent);

break;
case Axis.Z:
if (groundPlane.Raycast(ray, out ent))

float deltaPosZ = ray.GetPoint(ent).z - lastHitPos.z;
Tracked.position = new Vector3(Tracked.position.x, Tracked.position.y, Tracked.position.z + deltaPosZ);
lastHitPos = ray.GetPoint(ent);

break;



Fixed links!
Unity Editor: https://youtu.be/I0DAVa7GIeo

What I currently have: https://youtu.be/cTykv-KTNOY










share|improve this question
















I've been trying to implement a move tool similar to the one built into the unity editor. After failing to make it I've spent many hours trying to find a way to do it. I came up with this:



Plane groundPlane = new Plane(Vector3.up, Tracked.position);
Plane rightPlane = new Plane(Vector3.right, Tracked.position);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
switch (axis)

case Axis.X:
if (groundPlane.Raycast(ray, out ent))

float deltaPosX = ray.GetPoint(ent).x - lastHitPos.x;
Tracked.position = new Vector3(Tracked.position.x + deltaPosX, Tracked.position.y, Tracked.position.z);
lastHitPos = ray.GetPoint(ent);

break;
case Axis.Y:
if (rightPlane.Raycast(ray, out ent))

float deltaPosY = ray.GetPoint(ent).y - lastHitPos.y;
Tracked.position = new Vector3(Tracked.position.x, Tracked.position.y + deltaPosY, Tracked.position.z);
lastHitPos = ray.GetPoint(ent);

break;
case Axis.Z:
if (groundPlane.Raycast(ray, out ent))

float deltaPosZ = ray.GetPoint(ent).z - lastHitPos.z;
Tracked.position = new Vector3(Tracked.position.x, Tracked.position.y, Tracked.position.z + deltaPosZ);
lastHitPos = ray.GetPoint(ent);

break;



Fixed links!
Unity Editor: https://youtu.be/I0DAVa7GIeo

What I currently have: https://youtu.be/cTykv-KTNOY







c# unity3d






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 20 at 11:10









marc_s

599k135 gold badges1149 silver badges1285 bronze badges




599k135 gold badges1149 silver badges1285 bronze badges










asked Mar 26 at 21:09









Pitr _Pitr _

184 bronze badges




184 bronze badges















  • Looks good! What was the question?

    – Zock77
    Mar 26 at 22:56











  • I've messed up the links. Unity is under what I currently have.

    – Pitr _
    Mar 27 at 5:28











  • You may need to add an offset to the postion depending on where you clicked the arrow. That would keep it from jumping around like that.

    – Zock77
    Mar 27 at 15:29

















  • Looks good! What was the question?

    – Zock77
    Mar 26 at 22:56











  • I've messed up the links. Unity is under what I currently have.

    – Pitr _
    Mar 27 at 5:28











  • You may need to add an offset to the postion depending on where you clicked the arrow. That would keep it from jumping around like that.

    – Zock77
    Mar 27 at 15:29
















Looks good! What was the question?

– Zock77
Mar 26 at 22:56





Looks good! What was the question?

– Zock77
Mar 26 at 22:56













I've messed up the links. Unity is under what I currently have.

– Pitr _
Mar 27 at 5:28





I've messed up the links. Unity is under what I currently have.

– Pitr _
Mar 27 at 5:28













You may need to add an offset to the postion depending on where you clicked the arrow. That would keep it from jumping around like that.

– Zock77
Mar 27 at 15:29





You may need to add an offset to the postion depending on where you clicked the arrow. That would keep it from jumping around like that.

– Zock77
Mar 27 at 15:29












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366221%2fhow-to-implement-axis-dragging-in-unity%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55366221%2fhow-to-implement-axis-dragging-in-unity%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript