Skip to content

Commit 6a93654

Browse files
committed
Tutorial improvements again
1 parent 9a8b389 commit 6a93654

File tree

11 files changed

+50
-37
lines changed

11 files changed

+50
-37
lines changed

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/Assets/Scenes/03_Raycasting/Completed-Raycasting.sdscene

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Hierarchy:
202202
9a7f8a5f2a4dee8e21a358916c686069: ref!! ad45eb14-a372-4b8e-ab78-640cd773ff67
203203
d5fc5b9d4033b3675a0b46ddc44d0280: !CSharpIntermediate.Code.RaycastPenetratingDemo,CSharpIntermediate.Game
204204
Id: b15a1386-b2d5-4098-a34e-c53b31617f34
205-
CollideWithGroup: CustomFilter1
205+
CollideWithGroup: DefaultFilter, StaticFilter, KinematicFilter, DebrisFilter, SensorTrigger, CharacterFilter, CustomFilter2, CustomFilter3, CustomFilter4, CustomFilter5, CustomFilter6, CustomFilter7, CustomFilter8, CustomFilter9, CustomFilter10
206206
CollideWithTriggers: true
207207
79f1213321ddbd79da50fb28d0798030: !CSharpIntermediate.Code.OmniDirectionMovement,CSharpIntermediate.Game
208208
Id: 070c4dd1-8316-46d6-acc9-65d662867913
@@ -604,7 +604,7 @@ Hierarchy:
604604
Components:
605605
21639b2f688316c585e191db6981e6ea: !TransformComponent
606606
Id: b05306f0-b949-4817-b06a-9665935f9425
607-
Position: {X: 0.0, Y: 0.060330506, Z: -4.5027337}
607+
Position: {X: 0.0, Y: 0.060330506, Z: -4.2770786}
608608
Rotation: {X: 0.0, Y: 0.0, Z: 0.0, W: 1.0}
609609
Scale: {X: 0.66130906, Y: 0.66130906, Z: 0.66130906}
610610
Children: {}
@@ -1197,7 +1197,7 @@ Hierarchy:
11971197
Components:
11981198
21639b2f688316c585e191db6981e6ea: !TransformComponent
11991199
Id: 57fe2e7e-cfa6-48c9-a43c-5cc743e96aae
1200-
Position: {X: 0.0, Y: 2.0603304, Z: -4.5001907}
1200+
Position: {X: 0.0, Y: 2.0603304, Z: -4.2745357}
12011201
Rotation: {X: 0.0, Y: 1.0, Z: 0.0, W: -4.371139E-08}
12021202
Scale: {X: 0.66130906, Y: 0.66130906, Z: 0.66130906}
12031203
Children: {}
@@ -1513,7 +1513,7 @@ Hierarchy:
15131513
Components:
15141514
21639b2f688316c585e191db6981e6ea: !TransformComponent
15151515
Id: 26c2be03-ca3b-42b3-8471-14db962f7bde
1516-
Position: {X: 0.0, Y: 1.0603305, Z: -4.5001907}
1516+
Position: {X: 0.0, Y: 1.0603305, Z: -4.2745357}
15171517
Rotation: {X: 0.0, Y: 1.0, Z: 0.0, W: -4.371139E-08}
15181518
Scale: {X: 0.66130906, Y: 0.66130906, Z: 0.66130906}
15191519
Children: {}
@@ -1622,7 +1622,6 @@ Hierarchy:
16221622
5df289f2597cd279d9dcc05bc9e895fd~0: c5f8292f-4ef2-4417-b296-ca46f08b2411:Materials/Transparent
16231623
a611784bb47a2fd81a5464c73697642e: !StaticColliderComponent
16241624
Id: 32e82212-0b4f-4a47-b77e-22c51d71b3e1
1625-
CollisionGroup: CustomFilter1
16261625
CanSleep: false
16271626
Restitution: 0.0
16281627
Friction: 0.5

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/Assets/Scenes/06_SceneLoading/Completed-SceneA.sdscene

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ Hierarchy:
127127
Id: 19d7b33c-9f1c-40da-a04b-60ba49a2dc11
128128
SceneToLoad: d2f251fc-d4eb-43b8-b7e0-0247597eca81:Scenes/06_SceneLoading/Completed-SceneB
129129
DrawY: 20
130-
Info: To load Scene B, press
131-
KeyToPress: None
130+
Info: Scene-B, press
131+
KeyToPress: B
132132
- Folder: Ground
133133
Entity:
134134
Id: 147a295b-1b60-4e9c-81a7-c8ecee8ce3d6

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/Assets/Scenes/06_SceneLoading/Completed-SceneB.sdscene

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Hierarchy:
8181
LocalOffset: {X: 0.0, Y: 0.0, Z: 0.0}
8282
- Entity:
8383
Id: 86ea71e1-6822-4267-b0c5-3ca59ff226d2
84-
Name: ReloadSceneA
84+
Name: LoadSceneA
8585
Components:
8686
eb5035f857a0e6f5d775a26b64b3bf3f: !TransformComponent
8787
Id: 6802fa61-110f-4b11-ad35-e8616143f6b9
@@ -93,8 +93,8 @@ Hierarchy:
9393
Id: 890a1f70-25a0-4412-b94a-27ba469f1ac0
9494
SceneToLoad: f6f2a96e-6b05-4119-bba1-87c1fa5c8fdf:Scenes/06_SceneLoading/Completed-SceneA
9595
DrawY: 60
96-
Info: 'To go back to scene A, press '
97-
KeyToPress: None
96+
Info: Load scene-A, press
97+
KeyToPress: A
9898
- Entity:
9999
Id: 8d16a77c-de44-444c-9a80-48691f614e88
100100
Name: Gate1x2x1
@@ -123,8 +123,8 @@ Hierarchy:
123123
Id: c971497d-f0b0-4c4e-a922-4fdbac7ca9b5
124124
SceneToLoad: d2f251fc-d4eb-43b8-b7e0-0247597eca81:Scenes/06_SceneLoading/Completed-SceneB
125125
DrawY: 20
126-
Info: 'To reload scene, press '
127-
KeyToPress: None
126+
Info: Reload scene, press
127+
KeyToPress: B
128128
- Entity:
129129
Id: dbd15918-28c5-4576-8ee1-54c044e62e35
130130
Name: Gate2x3x1

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/Assets/Scenes/08_Audio/Completed-Audio.sdscene

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ Hierarchy:
793793
Environment: Small
794794
9b5c17fd501f9839aed554a74bc4575e: !CSharpIntermediate.Code.AudioDemo,CSharpIntermediate.Game
795795
Id: bb4b827c-f0e2-4a11-943e-2603cb6c83eb
796-
UkuleleSound: null
796+
UkuleleSound: 3885913c-4b28-49c8-b06f-5dbf54e7c5bb:Audio/Ukelele
797797
6f2d27198339238056f47fbe7f621748: !CSharpIntermediate.Code.OmniDirectionMovement,CSharpIntermediate.Game
798798
Id: e2bace7e-5a0c-404f-a436-c5edb10957df
799799
MoveSpeed: 3.0

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/Assets/Scenes/11_Navigation/Completed-Navigation.sdscene

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ Hierarchy:
786786
Id: 3b988948-2838-42f5-9191-0a1ffd6ddee3
787787
RegularCharacter: ref!! 8443a87b-1f25-4437-9f81-8898234cb94b
788788
PathSphere: ref!! ffc6dedb-c9b2-4f25-9332-265551b04467
789-
MovementSpeed: 2.5
789+
MovementSpeed: 1.8
790790
- Folder: Walls
791791
Entity:
792792
Id: 9a2aed26-aa9f-4a79-80b7-907e529418cd
@@ -1342,7 +1342,7 @@ Hierarchy:
13421342
Components:
13431343
5df3ae39ecbb00c7c2c349e3b004fc40: !TransformComponent
13441344
Id: ae8da9e8-e1aa-43a3-916e-2d4475a3d37f
1345-
Position: {X: 0.0, Y: -0.053181265, Z: 0.0}
1345+
Position: {X: 1.3935742, Y: -0.053181265, Z: -3.4938378}
13461346
Rotation: {X: 0.0, Y: 0.0, Z: 0.0, W: 1.0}
13471347
Scale: {X: 0.2, Y: 0.2, Z: 0.2}
13481348
Children: {}

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/02_Collision-Triggers/CollisionTriggerDemo.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,42 @@ public class CollisionTriggerDemo : SyncScript
1515

1616
public override void Start()
1717
{
18+
// Retrieve the Physics component of the current entity
1819
staticCollider = Entity.Get<StaticColliderComponent>();
20+
21+
// When the 'CollectionChanged' event occurs, execute the CollisionsChanged method
1922
staticCollider.Collisions.CollectionChanged += CollisionsChanged;
2023
}
2124

2225
private void CollisionsChanged(object sender, TrackingCollectionChangedEventArgs args)
2326
{
27+
// Cast the argument 'item' to a collision object
2428
var collision = (Collision)args.Item;
29+
30+
// We need to make sure which collision object is not the Trigger collider
31+
// We perform a little check to find the ballCollider
2532
var ballCollider = staticCollider == collision.ColliderA ? collision.ColliderB : collision.ColliderA;
2633

2734
if (args.Action == NotifyCollectionChangedAction.Add)
2835
{
36+
// When a collision has been added to the collision collection, we know an object has 'entered' our trigger
2937
collisionStatus = ballCollider.Entity.Name + " entered " + staticCollider.Entity.Name;
3038
}
3139
else if (args.Action == NotifyCollectionChangedAction.Remove)
3240
{
41+
// When a collision has been removed from the collision collection, we know an object 'left' our trigger
3342
collisionStatus = ballCollider.Entity.Name + " left " + staticCollider.Entity.Name;
3443
}
3544
}
3645

3746
public override void Update()
3847
{
48+
// The trigger collider can have 0, 1, or multiple collision going on in a single frame
49+
int drawX = 500, drawY = 300;
3950
foreach (var collision in staticCollider.Collisions)
4051
{
41-
DebugText.Print("ColliderA: " + collision.ColliderA.Entity.Name, new Int2(500, 300));
42-
DebugText.Print("ColliderB: " + collision.ColliderB.Entity.Name, new Int2(500, 320));
52+
DebugText.Print("ColliderA: " + collision.ColliderA.Entity.Name, new Int2(drawX, drawY += 20));
53+
DebugText.Print("ColliderB: " + collision.ColliderB.Entity.Name, new Int2(drawX, drawY += 20));
4354
}
4455

4556
DebugText.Print(collisionStatus, new Int2(500, 400));

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/03_Raycasting/RaycastDemo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net)
22
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3+
using CSharpIntermediate.Code.Extensions;
34
using Stride.Core.Mathematics;
45
using Stride.Engine;
56
using Stride.Physics;
@@ -25,7 +26,7 @@ public override void Start()
2526

2627
public override void Update()
2728
{
28-
int drawX = 400;
29+
int drawX = 340;
2930
int drawY = 80;
3031
DebugText.Print("Press Q and E to raise/lower weapons", new Int2(drawX, drawY));
3132

@@ -44,7 +45,7 @@ public override void Update()
4445

4546
DebugText.Print("Hit a collider", new Int2(drawX, drawY));
4647
DebugText.Print($"Raycast hit distance: {distance}", new Int2(drawX, drawY + 20));
47-
DebugText.Print($"Raycast hit point: {hitResult.Point}", new Int2(drawX, drawY + 40));
48+
DebugText.Print($"Raycast hit point: {hitResult.Point.Print()}", new Int2(drawX, drawY + 40));
4849
DebugText.Print($"Raycast hit entity: {hitResult.Collider.Entity.Name}", new Int2(drawX, drawY + 60));
4950
}
5051
else

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/03_Raycasting/RaycastPenetratingDemo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class RaycastPenetratingDemo : SyncScript
1313
public bool CollideWithTriggers = false;
1414

1515
private Entity laser;
16-
private const float maxDistance = 4.0f;
16+
private const float maxDistance = 3.0f;
1717
private Simulation simulation;
1818

1919
public override void Start()

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/07_Animation/AnimationBasics.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,28 @@ public override void Start()
2424

2525
public override void Update()
2626
{
27-
StopOrResumeAnimations();
27+
int drawX = 800, drawY = 600;
2828

29-
AdjustAnimationSpeed();
29+
StopOrResumeAnimations(drawX, drawY += 20);
3030

31-
DebugText.Print("I to start playing Idle", new Int2(320, 440));
31+
AdjustAnimationSpeed(drawX, drawY += 20);
32+
33+
DebugText.Print("I to start playing Idle", new Int2(drawX, drawY += 20));
3234
if (Input.IsKeyPressed(Keys.I))
3335
{
3436
latestAnimation = animation.Play("Idle");
3537
latestAnimation.TimeFactor = AnimationSpeed;
3638
}
3739

38-
DebugText.Print("R to crossfade to Run", new Int2(320, 460));
40+
DebugText.Print("R to crossfade to Run", new Int2(drawX, drawY += 20));
3941
if (Input.IsKeyPressed(Keys.R))
4042
{
4143
latestAnimation = animation.Crossfade("Run", TimeSpan.FromSeconds(0.5));
4244
latestAnimation.TimeFactor = AnimationSpeed;
4345
}
4446

4547
// We can crossfade to a punch animation, but only if it is not already playing
46-
DebugText.Print("P to crossfade to Punch and play it once", new Int2(320, 480));
48+
DebugText.Print("P to crossfade to Punch and play it once", new Int2(drawX, drawY += 20));
4749
if (Input.IsKeyPressed(Keys.P) && !animation.IsPlaying("Punch"))
4850
{
4951
latestAnimation = animation.Crossfade("Punch", TimeSpan.FromSeconds(0.1));
@@ -60,9 +62,9 @@ public override void Update()
6062
}
6163
}
6264

63-
private void StopOrResumeAnimations()
65+
private void StopOrResumeAnimations(int drawX, int drawY)
6466
{
65-
DebugText.Print($"S to pause or resume animations", new Int2(320, 420));
67+
DebugText.Print($"S to pause or resume animations", new Int2(drawX, drawY));
6668
if (Input.IsKeyPressed(Keys.S))
6769
{
6870
foreach (var playingAnimation in animation.PlayingAnimations)
@@ -72,9 +74,9 @@ private void StopOrResumeAnimations()
7274
}
7375
}
7476

75-
private void AdjustAnimationSpeed()
77+
private void AdjustAnimationSpeed(int drawX, int drawY)
7678
{
77-
DebugText.Print($"Q and E for speed {AnimationSpeed:0.0}", new Int2(320, 400));
79+
DebugText.Print($"Q and E for speed {AnimationSpeed:0.0}", new Int2(drawX, drawY));
7880
if (Input.IsKeyPressed(Keys.E))
7981
{
8082
AnimationSpeed += 0.1f;

samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/08_Audio/AudioDemo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ public override void Start()
2828
public override void Update()
2929
{
3030
// Play a sound
31-
DebugText.Print($"U to play the Ukelele once", new Int2(200, 40));
31+
DebugText.Print($"U to play the Ukelele once", new Int2(200, 580));
3232
if (Input.IsKeyPressed(Keys.U))
3333
{
3434
ukuleleInstance.Stop();
3535
ukuleleInstance.Play();
3636
}
3737

38-
// Press left mouse button fire gun
39-
DebugText.Print($"Press left mouse button fire gun", new Int2(200, 60));
40-
if (Input.IsMouseButtonPressed(MouseButton.Left))
38+
// Press right mouse button for gun fire sound
39+
DebugText.Print($"Press right mouse button fire gun", new Int2(200, 640));
40+
if (Input.IsMouseButtonPressed(MouseButton.Right))
4141
{
4242
gunSoundEmitter.Play();
4343
}

0 commit comments

Comments
 (0)