Fixed orientation-then-interaction.
parent
e5b73930ce
commit
f7dca6ae20
|
@ -2,7 +2,7 @@ using System;
|
||||||
|
|
||||||
public static class Globals
|
public static class Globals
|
||||||
{
|
{
|
||||||
public const float EpsPosition = 0.01f;
|
public const float EpsPosition = 0.02f;
|
||||||
public const float EpsPositionSquared = EpsPosition * EpsPosition;
|
public const float EpsPositionSquared = EpsPosition * EpsPosition;
|
||||||
public const float EpsRadians = 0.1f * Godot.Mathf.Pi / 180f;
|
public const float EpsRadians = 0.1f * Godot.Mathf.Pi / 180f;
|
||||||
public const float EpsRadiansSquared = EpsRadians * EpsRadians;
|
public const float EpsRadiansSquared = EpsRadians * EpsRadians;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,203 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
width="67.73333mm"
|
|
||||||
height="67.73333mm"
|
|
||||||
viewBox="0 0 67.73333 67.73333"
|
|
||||||
version="1.1"
|
|
||||||
id="svg1420"
|
|
||||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
|
||||||
sodipodi:docname="pirate.svg">
|
|
||||||
<defs
|
|
||||||
id="defs1414" />
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="base"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#666666"
|
|
||||||
borderopacity="1.0"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:zoom="1.979899"
|
|
||||||
inkscape:cx="193.12383"
|
|
||||||
inkscape:cy="128.13748"
|
|
||||||
inkscape:document-units="mm"
|
|
||||||
inkscape:current-layer="layer1"
|
|
||||||
showgrid="false"
|
|
||||||
inkscape:window-width="1916"
|
|
||||||
inkscape:window-height="1041"
|
|
||||||
inkscape:window-x="0"
|
|
||||||
inkscape:window-y="37"
|
|
||||||
inkscape:window-maximized="0"
|
|
||||||
fit-margin-top="0"
|
|
||||||
fit-margin-left="0"
|
|
||||||
fit-margin-right="0"
|
|
||||||
fit-margin-bottom="0"
|
|
||||||
showguides="false" />
|
|
||||||
<metadata
|
|
||||||
id="metadata1417">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<dc:title />
|
|
||||||
</cc:Work>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1"
|
|
||||||
transform="translate(-22.735567,-21.843752)">
|
|
||||||
<rect
|
|
||||||
style="fill:none;fill-opacity:1;stroke:none;stroke-width:1.16499996;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="rect2086"
|
|
||||||
width="67.73333"
|
|
||||||
height="67.73333"
|
|
||||||
x="22.735567"
|
|
||||||
y="21.843752" />
|
|
||||||
<ellipse
|
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.97067016;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path1965"
|
|
||||||
cx="58.817451"
|
|
||||||
cy="69.21006"
|
|
||||||
rx="12.306589"
|
|
||||||
ry="13.607285" />
|
|
||||||
<ellipse
|
|
||||||
style="fill:#ffccaa;fill-opacity:1;stroke:#000000;stroke-width:0.97067016;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path1967"
|
|
||||||
cx="58.517292"
|
|
||||||
cy="43.996555"
|
|
||||||
rx="12.806856"
|
|
||||||
ry="13.807391" />
|
|
||||||
<path
|
|
||||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.64763337;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="M 45.064956,44.376975 70.573747,37.843264"
|
|
||||||
id="path1971"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="cc" />
|
|
||||||
<path
|
|
||||||
style="fill:#1a1a1a;fill-rule:evenodd;stroke:#000000;stroke-width:0.57276243;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 51.618464,41.275314 0.383478,2.521691 1.51754,1.03021 2.8015,-0.100052 c 1.76379,-0.867768 1.776356,-2.027407 2.001071,-3.151687 z"
|
|
||||||
id="path1975"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="cccccc" />
|
|
||||||
<path
|
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.64763337;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 66.571604,49.474492 c -10e-7,0.870314 -5.010624,3.777022 -8.229406,3.777022 -3.218781,0 -8.129351,-3.156842 -8.129352,-4.027156 -10e-7,-0.870314 4.91057,0.875469 8.129352,0.875469 3.218782,0 8.229406,-1.495649 8.229406,-0.625335 z"
|
|
||||||
id="path1982"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="sssss" />
|
|
||||||
<ellipse
|
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.64763337;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path1985"
|
|
||||||
cx="64.220352"
|
|
||||||
cy="42.645832"
|
|
||||||
rx="2.501339"
|
|
||||||
ry="1.4507767" />
|
|
||||||
<ellipse
|
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.64763337;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path1987"
|
|
||||||
cx="64.320404"
|
|
||||||
cy="42.370686"
|
|
||||||
rx="0.95050877"
|
|
||||||
ry="0.92549545" />
|
|
||||||
<path
|
|
||||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.87224609;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 58.317186,44.346745 c -0.48074,1.110566 -2.780721,3.873885 0.100053,3.501876"
|
|
||||||
id="path1991"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="cc" />
|
|
||||||
<g
|
|
||||||
id="g2020"
|
|
||||||
transform="matrix(0.7487091,0,0,0.7487091,22.011525,15.311364)">
|
|
||||||
<rect
|
|
||||||
y="60.764866"
|
|
||||||
x="34.11235"
|
|
||||||
height="4.7613068"
|
|
||||||
width="29.098907"
|
|
||||||
id="rect1993"
|
|
||||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.16499996;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
<rect
|
|
||||||
y="70.426895"
|
|
||||||
x="31.608257"
|
|
||||||
height="5.3861618"
|
|
||||||
width="33.261906"
|
|
||||||
id="rect1993-3"
|
|
||||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.16499996;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
<rect
|
|
||||||
inkscape:transform-center-y="-1.7953869"
|
|
||||||
inkscape:transform-center-x="4.2522321"
|
|
||||||
y="80.801094"
|
|
||||||
x="34.773071"
|
|
||||||
height="3.9466267"
|
|
||||||
width="27.487846"
|
|
||||||
id="rect1993-6"
|
|
||||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.16499996;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
</g>
|
|
||||||
<path
|
|
||||||
style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1.24660063;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 42.10851,46.397844 11.91124,-6.273146 17.704613,-3.131888 -1.152956,-4.88569 -3.659617,-4.307194 -6.593533,-2.41333 -6.560565,1.23882 -6.046183,2.763322 -4.202251,12.206536 -5.602999,-3.001607 -1.400748,5.803105 5.002677,4.602464 z"
|
|
||||||
id="path1969"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="ccccccccccccc" />
|
|
||||||
<ellipse
|
|
||||||
style="fill:#ffff00;fill-opacity:1;stroke:#241c1c;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.28632483"
|
|
||||||
id="path891"
|
|
||||||
cx="71.115189"
|
|
||||||
cy="57.663963"
|
|
||||||
rx="4.9444861"
|
|
||||||
ry="7.4835467" />
|
|
||||||
<ellipse
|
|
||||||
style="fill:#ffff00;fill-opacity:1;stroke:#241c1c;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.28632483"
|
|
||||||
id="path893"
|
|
||||||
cx="70.914734"
|
|
||||||
cy="46.973183"
|
|
||||||
rx="3.4076865"
|
|
||||||
ry="4.4099469" />
|
|
||||||
<path
|
|
||||||
style="fill:#ffff00;fill-opacity:1;stroke:#241c1c;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.28632483"
|
|
||||||
d="m 76.576478,56.227926 c 0.974202,3.635771 0.665907,6.877365 -0.688596,7.240302 -1.354503,0.362937 -3.24229,-2.290218 -4.216492,-5.925988 -0.974202,-3.635771 -0.665907,-6.877365 0.688596,-7.240302 1.354503,-0.362937 3.24229,2.290218 4.216492,5.925988 z"
|
|
||||||
id="path895"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="sssss" />
|
|
||||||
<path
|
|
||||||
style="fill:#ffff00;fill-rule:evenodd;stroke:#c0be08;stroke-width:0.59500003;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 67.774315,45.866354 c 0,0 -2.666291,1.274117 -3.073598,2.53906 -0.268239,0.833048 0.668174,2.539061 0.668174,2.539061 l 1.202713,-1.469983 2.004521,-0.400904 z"
|
|
||||||
id="path897"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="cscccc" />
|
|
||||||
<path
|
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.28632483"
|
|
||||||
id="path899"
|
|
||||||
sodipodi:type="arc"
|
|
||||||
sodipodi:cx="-70.017845"
|
|
||||||
sodipodi:cy="-46.00531"
|
|
||||||
sodipodi:rx="1.0151163"
|
|
||||||
sodipodi:ry="1.603617"
|
|
||||||
sodipodi:start="0"
|
|
||||||
sodipodi:end="6.2530804"
|
|
||||||
d="m -69.002729,-46.00531 a 1.0151163,1.603617 0 0 1 -1.007476,1.603571 1.0151163,1.603617 0 0 1 -1.022641,-1.579434 1.0151163,1.603617 0 0 1 0.992083,-1.627345 1.0151163,1.603617 0 0 1 1.037574,1.554938 l -1.014656,0.04827 z"
|
|
||||||
transform="scale(-1)" />
|
|
||||||
<path
|
|
||||||
style="fill:#ffffff;fill-opacity:0.28627451;stroke:#000000;stroke-width:0.59499997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path901"
|
|
||||||
sodipodi:type="arc"
|
|
||||||
sodipodi:cx="69.808182"
|
|
||||||
sodipodi:cy="46.459103"
|
|
||||||
sodipodi:rx="0.20966499"
|
|
||||||
sodipodi:ry="0.45379427"
|
|
||||||
sodipodi:start="0"
|
|
||||||
sodipodi:end="6.2530784"
|
|
||||||
d="m 70.017847,46.459103 a 0.20966499,0.45379427 0 0 1 -0.208087,0.453781 0.20966499,0.45379427 0 0 1 -0.211219,-0.44695 0.20966499,0.45379427 0 0 1 0.204907,-0.46051 0.20966499,0.45379427 0 0 1 0.214304,0.440018 l -0.20957,0.01366 z" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 9.6 KiB |
|
@ -1,35 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="StreamTexture"
|
|
||||||
path="res://.import/pirate.svg-b5137b2528ef058c6c14f8ea13b79308.stex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/pirate.svg"
|
|
||||||
dest_files=[ "res://.import/pirate.svg-b5137b2528ef058c6c14f8ea13b79308.stex" ]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_mode=0
|
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
|
||||||
flags/repeat=0
|
|
||||||
flags/filter=true
|
|
||||||
flags/mipmaps=false
|
|
||||||
flags/anisotropic=false
|
|
||||||
flags/srgb=2
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
|
||||||
size_limit=0
|
|
||||||
detect_3d=true
|
|
||||||
svg/scale=1.0
|
|
Binary file not shown.
Before Width: | Height: | Size: 613 KiB |
|
@ -1,37 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="StreamTexture"
|
|
||||||
path.s3tc="res://.import/water_diffuse.png-a44afe07b3d35e565d86feee627a1afb.s3tc.stex"
|
|
||||||
path.etc2="res://.import/water_diffuse.png-a44afe07b3d35e565d86feee627a1afb.etc2.stex"
|
|
||||||
metadata={
|
|
||||||
"imported_formats": [ "s3tc", "etc2" ],
|
|
||||||
"vram_texture": true
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/water_diffuse.png"
|
|
||||||
dest_files=[ "res://.import/water_diffuse.png-a44afe07b3d35e565d86feee627a1afb.s3tc.stex", "res://.import/water_diffuse.png-a44afe07b3d35e565d86feee627a1afb.etc2.stex" ]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=2
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_mode=0
|
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
|
||||||
flags/repeat=true
|
|
||||||
flags/filter=false
|
|
||||||
flags/mipmaps=false
|
|
||||||
flags/anisotropic=false
|
|
||||||
flags/srgb=1
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
|
||||||
size_limit=0
|
|
||||||
detect_3d=false
|
|
||||||
svg/scale=1.0
|
|
BIN
assets/white.png
BIN
assets/white.png
Binary file not shown.
Before Width: | Height: | Size: 546 B |
|
@ -1,35 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="StreamTexture"
|
|
||||||
path="res://.import/white.png-936ea7d0834e1e21adf362ba74ff2135.stex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/white.png"
|
|
||||||
dest_files=[ "res://.import/white.png-936ea7d0834e1e21adf362ba74ff2135.stex" ]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_mode=0
|
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
|
||||||
flags/repeat=0
|
|
||||||
flags/filter=true
|
|
||||||
flags/mipmaps=false
|
|
||||||
flags/anisotropic=false
|
|
||||||
flags/srgb=2
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
|
||||||
size_limit=0
|
|
||||||
detect_3d=true
|
|
||||||
svg/scale=1.0
|
|
|
@ -121,7 +121,7 @@ public class GroundMotionComponent : Component
|
||||||
{
|
{
|
||||||
Quat entityRotation = new Quat(entityTransform.basis);
|
Quat entityRotation = new Quat(entityTransform.basis);
|
||||||
float slerpWeight = RotationSpeedRadPerSecond / (orientationErrorRadians / delta);
|
float slerpWeight = RotationSpeedRadPerSecond / (orientationErrorRadians / delta);
|
||||||
entityRotation = entityRotation.Slerp(targetOrientation, slerpWeight);
|
entityRotation = entityRotation.Slerp(targetOrientation, slerpWeight).Normalized();
|
||||||
entityTransform.basis = new Basis(entityRotation);
|
entityTransform.basis = new Basis(entityRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,11 @@ public class MovableComponent : Component
|
||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
public override void _Process(float delta)
|
public override void _Process(float delta)
|
||||||
{
|
{
|
||||||
Vector3 targetDir = Vector3.Zero;
|
|
||||||
Vector3 targetError = targetPosition - currentPosition;
|
Vector3 targetError = targetPosition - currentPosition;
|
||||||
|
|
||||||
if (targetError.LengthSquared() > 0.01)
|
if (targetError.LengthSquared() > 0.01)
|
||||||
{
|
{
|
||||||
targetDir = targetError.Normalized();
|
Vector3 targetDir = targetError.Normalized();
|
||||||
targetAngle = new Vector3(0, 0, 1).SignedAngleTo(targetDir, Vector3.Up);
|
targetAngle = new Vector3(0, 0, 1).SignedAngleTo(targetDir, Vector3.Up);
|
||||||
|
|
||||||
if (targetAngle - currentAngle > Mathf.Pi)
|
if (targetAngle - currentAngle > Mathf.Pi)
|
||||||
|
@ -58,7 +57,7 @@ public class MovableComponent : Component
|
||||||
currentAngle = springDamperResult.Item1;
|
currentAngle = springDamperResult.Item1;
|
||||||
currentAngularVelocity = springDamperResult.Item2;
|
currentAngularVelocity = springDamperResult.Item2;
|
||||||
|
|
||||||
// EmitSignal("OrientationUpdated", this.currentAngle);
|
EmitSignal("OrientationUpdated", this.currentAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Mathf.Abs(currentAngularVelocity) < 5 && Mathf.Abs(targetAngle - currentAngle) < 0.3)
|
if ((Mathf.Abs(currentAngularVelocity) < 5 && Mathf.Abs(targetAngle - currentAngle) < 0.3)
|
||||||
|
@ -70,7 +69,6 @@ public class MovableComponent : Component
|
||||||
|
|
||||||
currentPosition = springDamperResult.Item1;
|
currentPosition = springDamperResult.Item1;
|
||||||
currentVelocity = springDamperResult.Item2;
|
currentVelocity = springDamperResult.Item2;
|
||||||
|
|
||||||
}
|
}
|
||||||
currentVelocity.y = currentVelocity.y - 9.81f * delta;
|
currentVelocity.y = currentVelocity.y - 9.81f * delta;
|
||||||
currentPosition.y = currentPosition.y + currentVelocity.y * delta;
|
currentPosition.y = currentPosition.y + currentVelocity.y * delta;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://components/MovableComponent.gd" type="Script" id=1]
|
[ext_resource path="res://components/MovableComponent.cs" type="Script" id=1]
|
||||||
|
|
||||||
[node name="Movable" type="Node2D"]
|
[node name="Movable" type="Node"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
max_speed = 300
|
|
||||||
|
|
|
@ -58,14 +58,13 @@ public class NavigationComponent : Node
|
||||||
{
|
{
|
||||||
goalReached = true;
|
goalReached = true;
|
||||||
}
|
}
|
||||||
else if (Flags.HasFlag(NavigationPoint.NavigationFlags.Position) &&
|
else if (Flags == NavigationPoint.NavigationFlags.Position &&
|
||||||
positionErrorSquared < Globals.EpsPositionSquared)
|
positionErrorSquared < Globals.EpsPositionSquared)
|
||||||
{
|
{
|
||||||
goalReached = true;
|
goalReached = true;
|
||||||
}
|
}
|
||||||
else if (Flags.HasFlag(NavigationPoint.NavigationFlags.Orientation) &&
|
else if (Flags == NavigationPoint.NavigationFlags.Orientation &&
|
||||||
orientationError < Globals.EpsRadians)
|
orientationError < Globals.EpsRadians)
|
||||||
|
|
||||||
{
|
{
|
||||||
goalReached = true;
|
goalReached = true;
|
||||||
}
|
}
|
||||||
|
@ -174,11 +173,24 @@ public class NavigationComponent : Node
|
||||||
// _pathWorldNavigationPoints.Count);
|
// _pathWorldNavigationPoints.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ApplyExistingTransform(Transform worldTransform)
|
||||||
|
{
|
||||||
|
if (_currentGoal.Flags == NavigationPoint.NavigationFlags.Orientation)
|
||||||
|
{
|
||||||
|
_currentGoalPositionWorld = worldTransform.origin;
|
||||||
|
} else if (_currentGoal.Flags == NavigationPoint.NavigationFlags.Position)
|
||||||
|
{
|
||||||
|
_currentGoalOrientationWorld = worldTransform.basis.Quat();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void UpdateCurrentGoal(Transform currentTransformWorld)
|
public void UpdateCurrentGoal(Transform currentTransformWorld)
|
||||||
{
|
{
|
||||||
if (_pathWorldNavigationPoints.Count == 0)
|
if (_pathWorldNavigationPoints.Count == 0)
|
||||||
{
|
{
|
||||||
|
_currentGoalOrientationWorld = currentTransformWorld.basis.Quat();
|
||||||
|
_currentGoalPositionWorld = currentTransformWorld.origin;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +215,10 @@ public class NavigationComponent : Node
|
||||||
if (_currentGoal.IsReached(currentTransformWorld))
|
if (_currentGoal.IsReached(currentTransformWorld))
|
||||||
{
|
{
|
||||||
_pathWorldNavigationPoints.RemoveAt(0);
|
_pathWorldNavigationPoints.RemoveAt(0);
|
||||||
|
|
||||||
UpdateCurrentGoal();
|
UpdateCurrentGoal();
|
||||||
|
ApplyExistingTransform(currentTransformWorld);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_pathWorldNavigationPoints.Count == 0)
|
if (_pathWorldNavigationPoints.Count == 0)
|
||||||
|
|
|
@ -77,6 +77,15 @@ public class TaskQueueComponent : Component
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTask = Queue.Peek();
|
currentTask = Queue.Peek();
|
||||||
|
if (currentTask is NavigationTask)
|
||||||
|
{
|
||||||
|
NavigationTask navigationTask = (NavigationTask)currentTask;
|
||||||
|
if (navigationTask != null && navigationTask.NavigationPoint.Flags ==
|
||||||
|
NavigationComponent.NavigationPoint.NavigationFlags.Orientation)
|
||||||
|
{
|
||||||
|
GD.Print("Current task is orientation task!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -51,14 +51,11 @@ public class GoldBar : KinematicBody
|
||||||
velocity.y = velocity.y - 9.81f * delta;
|
velocity.y = velocity.y - 9.81f * delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
velocity = MoveAndSlide(velocity);
|
||||||
|
|
||||||
if (velocity.LengthSquared() < 0.01)
|
if (velocity.LengthSquared() < 0.01)
|
||||||
{
|
{
|
||||||
velocity = Vector3.Zero;
|
velocity = Vector3.Zero;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
velocity = MoveAndSlide(velocity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ public class Player : Entity
|
||||||
|
|
||||||
// private members
|
// private members
|
||||||
private MovableComponent _movable;
|
private MovableComponent _movable;
|
||||||
private Spatial _geometry;
|
|
||||||
private WorldInfoComponent _worldInfo;
|
private WorldInfoComponent _worldInfo;
|
||||||
private GroundMotionComponent _groundMotion;
|
private GroundMotionComponent _groundMotion;
|
||||||
private NavigationComponent _navigationComponent;
|
private NavigationComponent _navigationComponent;
|
||||||
|
@ -33,7 +32,6 @@ public class Player : Entity
|
||||||
_navigationComponent = (NavigationComponent)FindNode("Navigation", false);
|
_navigationComponent = (NavigationComponent)FindNode("Navigation", false);
|
||||||
_navigationComponent.TileWorld = _worldInfo.TileWorld;
|
_navigationComponent.TileWorld = _worldInfo.TileWorld;
|
||||||
TaskQueueComponent = new TaskQueueComponent();
|
TaskQueueComponent = new TaskQueueComponent();
|
||||||
_geometry = (Spatial)FindNode("Geometry", false);
|
|
||||||
|
|
||||||
_itemAttractorArea = (Area)FindNode("ItemAttractorArea", false);
|
_itemAttractorArea = (Area)FindNode("ItemAttractorArea", false);
|
||||||
if (_itemAttractorArea == null)
|
if (_itemAttractorArea == null)
|
||||||
|
|
|
@ -9,17 +9,17 @@
|
||||||
config_version=4
|
config_version=4
|
||||||
|
|
||||||
_global_script_classes=[ {
|
_global_script_classes=[ {
|
||||||
"base": "Node",
|
"base": "Reference",
|
||||||
"class": "ClickableComponent",
|
"class": "ClickableComponent",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://components/ClickableComponent.gd"
|
"path": "res://components/ClickableComponent.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "KinematicBody2D",
|
"base": "Reference",
|
||||||
"class": "CollisionLine",
|
"class": "CollisionLine",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://utils/CollisionLine.gd"
|
"path": "res://utils/CollisionLine.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Node",
|
"base": "Reference",
|
||||||
"class": "ColorComponent",
|
"class": "ColorComponent",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://components/ColorComponent.gd"
|
"path": "res://components/ColorComponent.gd"
|
||||||
|
@ -54,7 +54,7 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://utils/SpringDamper.gd"
|
"path": "res://utils/SpringDamper.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Sprite",
|
"base": "Reference",
|
||||||
"class": "TintedSpriteComponent",
|
"class": "TintedSpriteComponent",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://components/TintedSpriteComponent.gd"
|
"path": "res://components/TintedSpriteComponent.gd"
|
||||||
|
|
|
@ -197,8 +197,19 @@ public class Game : Spatial
|
||||||
_player.TaskQueueComponent.Reset();
|
_player.TaskQueueComponent.Reset();
|
||||||
_player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask(
|
_player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask(
|
||||||
new NavigationComponent.NavigationPoint(tile.GlobalTranslation)));
|
new NavigationComponent.NavigationPoint(tile.GlobalTranslation)));
|
||||||
}
|
|
||||||
|
|
||||||
|
// Vector3 direction = tile.GlobalTranslation - _player.GlobalTranslation;
|
||||||
|
// if (direction.LengthSquared() > 0.1)
|
||||||
|
// {
|
||||||
|
// direction = direction.Normalized();
|
||||||
|
//
|
||||||
|
// float angle_to_tile = _player.GlobalTransform.basis.z.SignedAngleTo(direction, Vector3.Up);
|
||||||
|
// GD.Print("Angle to tile: " + Mathf.Rad2Deg(angle_to_tile) + " Player basis z: " + _player.GlobalTransform.basis.z + " Direction: " + direction);
|
||||||
|
// Quat tile_direction = new Quat(Vector3.Up, angle_to_tile);
|
||||||
|
// _player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask(
|
||||||
|
// new NavigationComponent.NavigationPoint(_player.GlobalTransform.basis.Rotated(Vector3.Up, angle_to_tile).Quat())));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
public void OnEntityClicked(Entity entity)
|
public void OnEntityClicked(Entity entity)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[ext_resource path="res://scenes/StreamContainer.cs" type="Script" id=1]
|
[ext_resource path="res://scenes/StreamContainer.cs" type="Script" id=1]
|
||||||
[ext_resource path="res://components/NavigationComponent.cs" type="Script" id=2]
|
[ext_resource path="res://components/NavigationComponent.cs" type="Script" id=2]
|
||||||
[ext_resource path="res://entities/Player.cs" type="Script" id=3]
|
[ext_resource path="res://entities/Player.cs" type="Script" id=3]
|
||||||
[ext_resource path="res://components/MovableComponent.cs" type="Script" id=4]
|
[ext_resource path="res://components/MovableComponent.tscn" type="PackedScene" id=4]
|
||||||
[ext_resource path="res://utils/TileHighlight.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://utils/TileHighlight.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://components/WorldInfoComponent.cs" type="Script" id=6]
|
[ext_resource path="res://components/WorldInfoComponent.cs" type="Script" id=6]
|
||||||
[ext_resource path="res://entities/Chest.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://entities/Chest.tscn" type="PackedScene" id=7]
|
||||||
|
@ -268,8 +268,7 @@ visible = false
|
||||||
mesh = SubResource( 15 )
|
mesh = SubResource( 15 )
|
||||||
skeleton = NodePath("../../..")
|
skeleton = NodePath("../../..")
|
||||||
|
|
||||||
[node name="Movable" type="Node" parent="Player"]
|
[node name="Movable" parent="Player" instance=ExtResource( 4 )]
|
||||||
script = ExtResource( 4 )
|
|
||||||
|
|
||||||
[node name="Geometry" type="Spatial" parent="Player"]
|
[node name="Geometry" type="Spatial" parent="Player"]
|
||||||
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
||||||
|
@ -303,7 +302,7 @@ shape = SubResource( 23 )
|
||||||
[node name="Entities" type="Spatial" parent="."]
|
[node name="Entities" type="Spatial" parent="."]
|
||||||
|
|
||||||
[node name="Chest" parent="Entities" instance=ExtResource( 7 )]
|
[node name="Chest" parent="Entities" instance=ExtResource( 7 )]
|
||||||
transform = Transform( -0.068085, 0, -0.99768, 0, 1, 0, 0.99768, 0, -0.068085, 2.01499, 0, -1.3224 )
|
transform = Transform( -0.510903, 0, 0.859639, 0, 1, 0, -0.859639, 0, -0.510903, 0.0770743, 0, 2.60865 )
|
||||||
|
|
||||||
[node name="Chest3" parent="Entities" instance=ExtResource( 7 )]
|
[node name="Chest3" parent="Entities" instance=ExtResource( 7 )]
|
||||||
transform = Transform( 0.550568, 0, -0.83479, 0, 1, 0, 0.83479, 0, 0.550568, 4.88275, 0, -1.70504 )
|
transform = Transform( 0.550568, 0, -0.83479, 0, 1, 0, 0.83479, 0, 0.550568, 4.88275, 0, -1.70504 )
|
||||||
|
|
Loading…
Reference in New Issue