Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
var EmptySlot : Transform;
var xtemp;
var ytemp;

function OnMouseUp(){

if(Vector3.Distance(transform.position, slot.position) == 1){
xtemp = transform.position.x;
ytemp = transform.position.y;
transform.position.x = slot.position.x;
transform.position.y = slot.position.y;
slot.position.x = xtemp;
slot.position.y = ytemp;
}
}


What I have tried:

I've tried this site Convert unity javascript (unityscript) to C#[^] [^] but it didn't really help me much.
Posted
Updated 4-Feb-18 0:06am
v2
Comments
Maciej Los 4-Feb-18 6:08am    
What's framework: WinForm, WPF, ASP.NET, ...?
Richard MacCutchan 4-Feb-18 8:02am    
It rather depends on what all those variables represent, and what Vector3.Distance is supposed to do.
Member 13660082 4-Feb-18 16:18pm    
It's actually for a tile puzzle game and the Vector3.Distance is so that only those near the empty slot will go to that empty slot.
Ziee-M 5-Feb-18 8:03am    
This is a Unity3D javascript code, give as much informations for users to help you.
You can use the unity3d scripting refrence to translate all this to C#, it will take you fews minutes. just search for the method name (Distance) and check the code written for it in both javascript and C#.
The API is really intresting, always go back to it for examples:
https://docs.unity3d.com/ScriptReference/Vector3.Distance.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900