-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
156 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Netherlands3D.Coordinates; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Netherlands3D.Twin | ||
{ | ||
public class WorldMovingAsset : WorldAsset | ||
{ | ||
public double latTarget, lonTarget; | ||
|
||
private Vector3 target; | ||
private bool moveToTarget = false; | ||
public float moveSpeed = 1; | ||
|
||
protected Coordinate targetCoord; | ||
|
||
public override void Start() | ||
{ | ||
base.Start(); | ||
|
||
|
||
} | ||
|
||
protected override void OnSetStartPosition(Vector3 startPosition) | ||
{ | ||
base.OnSetStartPosition(startPosition); | ||
targetCoord = new Coordinate(CoordinateSystem.WGS84, latTarget, lonTarget, 0); | ||
Vector3 unityCoord = targetCoord.ToUnity(); | ||
unityCoord.y = startPosition.y; | ||
target = unityCoord; | ||
} | ||
|
||
private void UpdateCoords() | ||
{ | ||
//startPosition = | ||
} | ||
|
||
public override void Update() | ||
{ | ||
base.Update(); | ||
if (moveToTarget) | ||
{ | ||
float dist = Vector3.Distance(prefab.transform.position, target); | ||
if (dist > 1f) | ||
{ | ||
prefab.transform.position = Vector3.Slerp(prefab.transform.position, target, Time.deltaTime * moveSpeed); | ||
} | ||
else | ||
moveToTarget = false; | ||
} | ||
else | ||
{ | ||
float dist = Vector3.Distance(prefab.transform.position, startPosition); | ||
if (dist > 1f) | ||
{ | ||
prefab.transform.position = Vector3.Slerp(prefab.transform.position, startPosition, Time.deltaTime * moveSpeed); | ||
} | ||
else | ||
moveToTarget = true; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.