Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curvedflats
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flatland
curvedflats
Commits
bc71de59
Commit
bc71de59
authored
Aug 15, 2019
by
Chae Ho Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Double Click complete, trajectory movement WIP
parent
ea61a883
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
30 deletions
+53
-30
FlatlandMovement.cs
Assets/Scripts/FlatlandMovement.cs
+19
-4
PathRenderer.cs
Assets/Scripts/PathRenderer.cs
+34
-6
UIManager.cs
Assets/Scripts/UIManager.cs
+0
-20
No files found.
Assets/Scripts/FlatlandMovement.cs
View file @
bc71de59
...
...
@@ -191,21 +191,36 @@ public class FlatlandMovement : MonoBehaviour
var
deltav
=
V
.
DenseOfArray
(
tmp
);
if
(
startv
.
magnitude
>
0.0f
)
{
deltav
=
Constants
.
BoostMatrix
(
startv
)
*
deltav
;
deltav
.
Normalize
(
2
);
deltav
=
deltav
*
atmp
;
var
deltavsize
=
Mathf
.
Sqrt
((
float
)(
deltav
[
1
]
*
deltav
[
1
]
+
deltav
[
2
]
*
deltav
[
2
]));
deltav
=
atmp
/
deltavsize
*
deltav
;
deltav
[
0
]
=
Constants
.
Gamma
(
atmp
)
*
Constants
.
c
;
deltav
[
1
]
*=
Constants
.
Gamma
(
atmp
);
deltav
[
2
]
*=
Constants
.
Gamma
(
atmp
);
deltav
=
Constants
.
BoostMatrix
(-
startv
)
*
deltav
;
}
else
{
var
deltavsize
=
Mathf
.
Sqrt
((
float
)(
deltav
[
1
]
*
deltav
[
1
]
+
deltav
[
2
]
*
deltav
[
2
]));
deltav
=
atmp
/
deltavsize
*
deltav
;
deltav
[
0
]
=
Constants
.
Gamma
(
atmp
)
*
Constants
.
c
;
deltav
[
1
]
*=
Constants
.
Gamma
(
atmp
);
deltav
[
2
]
*=
Constants
.
Gamma
(
atmp
);
}
var
tt
=
deltav
[
0
]
/
Constants
.
c
;
Vector3
finaldeltav
=
new
Vector3
((
float
)(
deltav
[
1
]
/
tt
),
0.0f
,
(
float
)(
deltav
[
2
]
/
tt
));
levelManager
.
player
.
v
=
finaldeltav
;
*/
levelManager
.
player
.
v
=
finaldeltav
;
}
...
...
Assets/Scripts/PathRenderer.cs
View file @
bc71de59
...
...
@@ -200,16 +200,21 @@ public class PathRenderer : MonoBehaviour
while
(
i
<=
finalPathNum
)
{
Vector3
acceleration
=
new
Vector3
(
square
.
GetNthPath
(
i
).
x
,
0f
,
square
.
GetNthPath
(
i
).
y
);
Vector3
acceleration
=
new
Vector3
(
square
.
GetNthPath
(
i
).
x
,
0f
,
square
.
GetNthPath
(
i
).
y
);
acceleration
.
Normalize
();
var
offsetstartpos
=
Background
.
transform
.
position
;
var
startpos
=
levelManager
.
player
.
transform
.
position
;
acceleration
=
acceleration
.
normalized
;
var
deltat
=
Time
.
fixedDeltaTime
*
tinterval
;
var
v
=
square
.
GetPathVelocity
(
i
)
*
Constants
.
c
;
var
v
=
square
.
GetPathVelocity
(
i
);
acceleration
=
(
float
)((
Constants
.
c
/
deltat
)
*
MathNet
.
Numerics
.
Trig
.
Asinh
(
v
*
Constants
.
Gamma
(
v
*
Constants
.
c
)))
*
acceleration
;
// acceleration required to accelerate to v in deltat seconds: see https://en.wikiversity.org/wiki/Theory_of_relativity/Rindler_coordinates
acceleration
=
(
float
)(
v
*
Constants
.
Gamma
(
v
)
/
deltat
)
*
acceleration
;
var
startv
=
levelManager
.
player
.
v
;
levelManager
.
player
.
alpha
=
acceleration
;
...
...
@@ -217,13 +222,33 @@ public class PathRenderer : MonoBehaviour
{
yield
return
new
WaitForFixedUpdate
();
}
levelManager
.
player
.
alpha
=
new
Vector3
(
0
,
0
,
0
);
var
offsetnewpos
=
Background
.
transform
.
position
;
var
newpos
=
levelManager
.
player
.
transform
.
position
;
var
posdiff
=
newpos
-
startpos
;
var
offset
=
offsetnewpos
-
offsetstartpos
;
posdiff
=
posdiff
-
offset
;
while
(
true
)
{
var
tmp
=
(
square
.
GetDestPoint
(
i
)
+
Background
.
transform
.
position
-
levelManager
.
player
.
transform
.
position
);
if
((
posdiff
-
tmp
).
magnitude
<
0.01f
)
break
;
yield
return
new
WaitForFixedUpdate
();
}
acceleration
=
-
acceleration
;
for
(
var
j
=
0
;
j
<
1000
;
++
j
)
levelManager
.
player
.
alpha
=
acceleration
;
for
(
var
j
=
0
;
j
<
tinterval
;
++
j
)
{
yield
return
new
WaitForFixedUpdate
();
}
levelManager
.
player
.
alpha
=
new
Vector3
(
0
,
0
,
0
);
Background
.
Toggle
=
true
;
...
...
@@ -231,6 +256,9 @@ public class PathRenderer : MonoBehaviour
i
++;
}
}
public
void
DeletePathsAfterNthPath
(
int
n
)
{
square
.
pathList
.
RemoveRange
(
n
,
_pathRenderer
.
positionCount
-
n
);
...
...
Assets/Scripts/UIManager.cs
View file @
bc71de59
...
...
@@ -226,26 +226,6 @@ public class UIManager : MonoBehaviour
StartCoroutine
(
pathRenderer
.
_StartMovingPath
(
prevSelectPathNum
));
}
bool
result
;
var
positions
=
pathRenderer
.
PathPositionsXZ
;
var
velocitys
=
pathRenderer
.
PathVelocitys
;
if
(
positions
.
Count
<=
1
||
velocitys
.
Count
<=
1
)
{
return
;
}
// remove dummy
positions
.
RemoveAt
(
0
);
velocitys
.
RemoveAt
(
0
);
result
=
levelManager
.
player
.
MoveToRetivePosition
(
positions
,
velocitys
);
if
(
result
)
{
pathRenderer
.
PathClear
();
}
}
public
void
PathCancel
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment