Unreal Engine 5 - AI Driven Cars

CodeLikeMe
22 Aug 202243:02

Summary

TLDRこのビデオでは、AIが運転する車を実装する方法が解説されています。車はスプラインに沿って自動的に進むようにプログラムされています。車は人間のプレイヤーのように、加速度とステアリングを使用しますが、加速度とステアリングの量はコードによって決定されます。スプラインを使用して軌道に沿って車を動かす方法を学びます。目標は、車が与えられた速度で軌道に沿って自動的に進むことです。スプラインのポイントをブループリントから取得する方法がないため、新しいフォルダを作成し、アクタークラスを追加します。車のブループリントを作成し、スプラインを参照する変数を追加します。車が前進するように制御し、最大速度を設定します。次に、車が曲がる方法を決定します。車のステアリングを制御するために、車には左と右の2つの参照ポイントがあります。これらのポイントを使用して、車が右ターン、左ターン、またはステアリングを行うべきかどうかを判断します。最後に、車がスプラインの終点に達したときにループを続ける方法を学びます。デモンストレーションでは、車がスプラインに沿って滑走路を顺利完成し、繰り返しループが可能です。

Takeaways

  • 🚗 自動運転車の実装について解説しています。車はスプラインに沿って動くだけでなく、加速度やステアリングをコードで決定します。
  • 📂 プロジェクトを作成する際には、スターターコンテンツは必要ありません。独自のフォルダとプロジェクト名を設定しましょう。
  • 🔄 スプラインを使用する際には、ランスケープスプラインアクターからブループリントにポイントを取得する方法が必要です。
  • 🛣️ スプラインの形状を調整する際には、ALTキーを押しながらポイントを動かすことで、ポイントを複製できます。
  • 🚦 スプラインに沿って車の進行方向を決定するために、左ポイント(LP)と右ポイント(RP)を設定します。
  • 📏 ターゲット地点までの距離を計算し、車が右か左に曲がるべきかを判断します。
  • 🚦 スプラインの長さを超えた場合、ループさせて車が継続的に進むように設定します。
  • 🏎️ 車の速度を制御するために、最大速度を設定し、速度がその値を下回る場合にのみ加速させます。
  • 🔧 車がスプラインに沿って滑らかに進むように、ステアリングの調整を行います。
  • 🔄 車がスプラインの端に到達した際に、スプラインの長さをゼロに戻してループを続けます。
  • 📉 車が曲がる角度を滑らかにするために、ステアリングの変化率をフレームレートから独立させます。
  • 🔗 プロジェクトファイルはPatreonページでダウンロード可能で、サポートが必要な場合はPatreonクライバーシップを検討できます。

Q & A

  • AIが運転する車はどのようにして軌道に沿って運転するようになりますか?

    -AIが運転する車は、コードを通じて加速度とステアリングを決定し、車両モーメントコンポーネントを使用して運転します。これは人間プレイヤーと同様ですが、加速度の量とステアリングはコードによって決定されます。

  • スプラインを使用して車をどのように制御しますか?

    -スプラインを使用する場合、スプラインポイントからブループリントにポイントを取得する方法が分からないため、新しいフォルダを作成し、アクタークラスを追加して、デフォルトで2つのポイントを持つようにします。

  • AIが運転する車の速度をどのように制御しますか?

    -車の速度を制御するために、車の前進速度を取得し、設定した最大速度値(例: 40km/h)以下であれば加速を適用するようにします。

  • AIが運転する車が壁にぶつからないようにするにはどうすればよいですか?

    -車が壁にぶつかないように、車にセンサーのようなコンポーネントを追加し、スプラインから得られるポイントと比較して、左または右にステアリングするかどうかを決定します。

  • AIが運転する車がスプラインに沿って滑走路を続けるためには何が必要ですか?

    -スプラインの長さを超えた場合、スプライン距離をリセットしてゼロに戻す必要があります。これにより、車がループ内で継続的に滑走路を続けることができます。

  • AIが運転する車が曲がる方向をどのように決定しますか?

    -AIが運転する車が曲がる方向を決定するために、スプラインから得られるポイントと車の参照ポイントとの距離を計算し、どちらが近いかに基づいて左または右に曲がる方向を決定します。

  • 車が揺れ動くのを防ぐためには何をしますか?

    -車が揺れ動くのを防ぐために、ステアリング量を徐々に変更するようにします。これは、ターゲット量から現在値への変更を、デルタ秒数と一定の乗数(例: 40)で乗算することで実現します。

  • AIが運転する車の速度を上げるにはどうすればよいですか?

    -AIが運転する車の速度を上げるには、最大速度の設定値を上げる(例: 50km/h)ことで、車がより速く運転できるようになります。

  • プロジェクトファイルはどこでダウンロードできますか?

    -プロジェクトファイルは、Patreonページからダウンロードできます。Patreonページのリンクは説明欄に記載されています。

  • AIが運転する車の開発に興味を持ってくださった方々はどのようにサポートできますか?

    -AIが運転する車の開発に興味を持ってくださった方々は、Patreonクラブのメンバーシップを取得してサポートすることができます。

  • AIが運転する車の開発で使用された主要な技術は何ですか?

    -AIが運転する車の開発で使用された主要な技術には、車両モーメントコンポーネント、スプラインを使用した経路制御、加速度とステアリングのコードによる決定、およびループでの連続運転のためのスプライン距離のリセットが含まれます。

  • AIが運転する車の開発で直面した最大の課題は何でしたか?

    -AIが運転する車の開発で直面した最大の課題は、車がスプラインに沿って滑走路を続ける方法、特に曲がり角の処理と車が揺れ動かないようにすることです。

Outlines

00:00

🚗 AI駆動車の実装方法

AI駆動車の実装方法について説明しています。車はコードによって運転され、加速度やステアリングを人間のように使用しますが、加速度の量やステアリングはコードで決定されます。ゲームと車両テンプレートを選択し、プロジェクトを作成します。目標は、車がスプラインに沿って自動的に進むようにすることです。スプラインを使用する際のポイントの取得方法についても説明しています。

05:02

🔄 車両ブループリントのカスタマイズ

車両のブループリントをカスタマイズし、AIが車を自動運転させる方法について説明しています。スプラインに沿って車を動かすために、スプラインポイントを複製する方法や、角度スナップを無効にする方法を紹介しています。また、車両ブループリントで子ブループリントを作成し、スプラインを参照する変数を追加する方法も説明されています。

10:02

🚦 加速と速度制御

AIが車を自動運転させる際の加速と速度制御について説明しています。車を前進させるために、加速のカスタムイベントを追加し、最大速度を設定する方法を説明しています。車が壁にぶつかないように、速度を40km/h以下に制御する方法についても紹介されています。

15:07

🔍 スプラインの参照と進捗の確認

スプラインの参照を取得し、AIがスプラインに沿って進むように制御する方法について説明しています。スプラインの各ポイントの位置を取得し、車が目標地点に到達するまでの距離を計算する方法を紹介しています。また、車がスプラインの進捗状況を確認する方法も説明されています。

20:08

🛣️ ステアリングの制御

AIが車を自動運転させる際のステアリング制御について説明しています。車にセンサーとして機能する参照ポイントを追加し、スプライン上のポイントの位置を取得して、車が右または左に曲がるべきかどうかを判断する方法を紹介しています。また、車がスプラインに沿って滑らかに進むように、ステアリングの調整方法も説明されています。

25:11

🔁 ループでの動作確認

スプラインの最後で車の動作を確認し、ループで動作するように設定する方法について説明しています。スプラインの長さを超えた場合に、スプラインの距離をリセットしてループを続ける方法を紹介しています。また、車がスプラインに沿って滑らかに進むように、ステアリングの調整と速度の制御方法も説明されています。

30:11

🏁 完成とプロジェクトファイルの提供

AIが車を自動運転させるプロセスが完了し、プロジェクトファイルが提供されることについて説明しています。車がスプラインに沿って滑らかに進む最終デモンストレーションを行い、車速度を50km/hに設定して2周続けて動作を確認しています。また、プロジェクトファイルはPatreonページからダウンロードできると発表しています。

Mindmap

Keywords

💡AI駆動車

AI駆動車とは、人工知能によって運転される車を指します。このビデオでは、AI駆動車の実装方法が説明されており、車はスプラインに沿って自動的に進むようにプログラムされています。これは、人間が運転する場合と同様に、加速度やステアリングを用いて車を制御するが、加速度やステアリングの量はコードによって決定されます。

💡スプライン

スプラインは、数学やコンピュータグラフィックスで使用される曲線の一種で、複数の制御点を通る滑らかな曲線を生成します。ビデオでは、スプラインを使用してAI駆動車が進む経路を定義しています。スプラインに沿って車を動かすために、スプラインから得られるポイントを使用して、車の進路を制御しています。

💡ブループリント

ブループリントは、 Unreal Engine などのゲームエンジンで使用されるビジュアルスクリプト言語です。ビデオでは、ブループリントを使用してAI駆動車の振る舞いを定義しています。具体的には、スプラインに沿って車を動かすためのロジックや、車の速度を制御するためなどのプロセスをブループリントで記述しています。

💡加速度

加速度は、物体の速度が変化する速さを表す物理用語で、AI駆動車が前進する速さを制御するために使用されます。ビデオでは、AI駆動車に加速度を適用することで、車がスプラインに沿って一定の速度で進むようにプログラムされています。

💡ステアリング

ステアリングは、車輪の回転方向を制御するメカニズムで、AI駆動車が曲がり角を通過する際に使用されます。ビデオでは、車がスプラインのカーブに沿って曲がるよう、ステアリングの量をコードで決定しています。

💡車両運動コンポーネント

車両運動コンポーネントは、ゲームエンジン内の車両の動きを制御する機能です。ビデオでは、このコンポーネントを使用してAI駆動車の加速度やステアリングをプログラムしています。また、車の前進速度を取得し、最大速度を設定する際にも使用されています。

💡カスタムイベント

カスタムイベントは、ブループリント内で定義され、特定のアクションをトリガーするために使用されます。ビデオでは、加速とターンのカスタムイベントを使って、AI駆動車の動作を制御しています。これにより、车がスプラインに沿って進む際に必要な加速度やステアリングを適用できます。

💡参照ポイント

参照ポイントとは、スプラインに沿って車を動かす際に使用される、車両の特定の部分を指す座標です。ビデオでは、左ポイント(lp)と右ポイント(rb)という2つの参照ポイントを使って、車がスプラインのカーブに沿って曲がる方向を決定しています。

💡距離計算

距離計算は、車と参照ポイントまたはターゲットポイント間の距離を求めるプロセスです。ビデオでは、車がスプラインに沿って進むために、車と参照ポイントの間の距離を計算して、ステアリング量を決定しています。

💡ループ

ループは、プログラムで繰り返し実行されるコードブロックです。ビデオでは、AI駆動車がスプラインの終点に達してもループして再度始点から開始できるように、スクリプト内でループを実装しています。これにより、車はスプラインを無限に繰り返し進むことができます。

💡パトロンページ

パトロンページとは、クリエイターがファンや支援者に対して特別なコンテンツや報酬を提供するプラットフォームです。ビデオの最後で、プロジェクトファイルがパトロンページからダウンロードできると告知されており、支援者にとっては特典として機能しています。

Highlights

Introduction of AI-driven cars that mimic human driving behavior through code.

Use of vehicle moment components such as acceleration and steering in AI cars.

Decision-making for acceleration and steering is coded, not manual.

Selection of games and vehicle template to start the project without starter content.

Creating a folder named 'vehicles' for organizing project files.

AI car's path-following is achieved by adhering to a spline.

Landscape spline actors are used, but extracting points for blueprints is challenging.

Quick tip: Holding 'Alt' while moving spline points allows for duplication.

Disabling angle snapping to move spline points freely.

Creating an actor class 'BP_Road' with two spline points as a starting point.

Implementation of a child blueprint for the vehicle with a variable of type 'BP_Road'.

Introduction of custom events 'accelerate' and 'turn' for autonomous driving.

Defining a maximum speed for the AI car to prevent collisions.

Using vehicle movement component to get forward speed and control acceleration.

Employing a selection mechanism to apply acceleration based on current speed.

Incorporating a loop for the AI car to continuously follow the spline path.

Utilizing reference points (left and right points) for detecting steering direction.

Calculating the distance to target points on the spline for steering decisions.

Smoothing out steering with a lap and delta seconds for a more natural turn.

Adjusting the 'check gap' and 'distance in payment cap' for better corner handling.

Final demonstration of AI car driving at 50 km/h for two consecutive rounds without issues.

Project files and Patreon support information provided for further engagement.

Transcripts

play00:00

hello everyone so today we are going to

play00:03

implement this ai driven cars

play00:06

as you can see here these cars are

play00:09

driven by

play00:11

through the code so

play00:13

it's not like exactly they are just

play00:16

moved through moved along a spline

play00:19

these cars actually use the vehicle

play00:23

moment components they use acceleration

play00:25

and steering just like a human player

play00:29

but instead the acceleration amounts and

play00:32

the steering is decided through the code

play00:35

so

play00:37

yeah

play00:38

let's see how to implement this system

play00:40

today so these guys can just

play00:43

continuously go through

play00:45

this track

play00:47

in a given speed continuously

play00:57

okay so i'll select games and vehicle

play01:01

template

play01:02

and

play01:04

i think i already have a

play01:06

folder named vehicle

play01:10

oh no okay

play01:14

vehicles

play01:16

and i'll name this

play01:23

ai

play01:24

cause

play01:28

i don't need starter content so let's

play01:31

create the project

play01:35

right now this is what i have

play01:39

um

play01:41

let me play

play01:49

okay so it is basically working

play01:52

so

play01:53

my goal is to

play01:56

make the car

play01:57

automatically drive

play01:59

in this path

play02:02

follow in a spline

play02:05

so how can we do that

play02:08

first

play02:09

uh

play02:10

these uh splines

play02:13

but landscape spline actors so we don't

play02:16

really have a

play02:17

i don't really know a way to get points

play02:21

from this into a blueprint

play02:23

so

play02:24

let's create a new folder

play02:28

be

play02:32

blueprints

play02:40

and let's create an actor class

play02:44

pp

play02:46

root

play02:54

right here

play02:57

let's add

play02:58

spline

play03:05

and by default let's

play03:08

have

play03:12

two points

play03:14

like this

play03:19

compile

play03:20

and

play03:23

that should be the starting point

play03:26

let's see here

play03:28

yeah this is

play03:30

also the player start

play03:32

so let's put

play03:40

where is it

play03:49

bp road here

play03:58

hmm right

play04:00

now let me make this road

play04:16

match this road

play04:48

so by the way if you keep alt pressed

play04:52

and move one of these spline points you

play04:55

can duplicate it

play04:57

quick tip if you don't already know that

play05:01

let me disable angle snapping

play05:05

so i can

play05:09

move it freely

play05:17

i don't need to have an exact

play05:21

map

play05:23

for this plane into the

play05:25

into this

play05:32

road underneath just a rough one or two

play05:36

but anyway i try to make it match

play05:41

as

play05:44

best as possible

play05:48

as close as possible

play06:13

okay

play06:27

[Music]

play06:29

right

play06:30

so this is this line

play06:32

and

play06:33

it starts

play06:36

from here and ends from here

play06:40

now

play06:45

where is the vehicle blueprint

play07:00

here here i'll create

play07:03

a child blueprint

play07:11

hey

play07:16

and place one here

play07:26

and

play07:27

now

play07:28

open the icar

play07:31

and

play07:35

here

play07:36

i'll add

play07:38

a variable

play07:45

what

play07:47

this should be from the type bp

play07:50

rod

play07:55

i'll make

play07:56

this instance irritable so we can assign

play08:00

this in

play08:01

here

play08:06

pp road

play08:08

okay

play08:12

now

play08:17

here

play08:18

uh

play08:18

[Music]

play08:20

in the tick

play08:23

so

play08:24

if i go to the parent

play08:27

of the ai car

play08:29

you can see user inputs

play08:34

where is it

play08:37

for throttle and

play08:39

yeah this move forward

play08:42

is connected to throttle and move right

play08:45

is connected to steering so here i'll

play08:48

add

play08:50

a custom event

play08:57

accelerate

play09:07

and

play09:08

[Music]

play09:09

we need to float

play09:11

input

play09:13

just like this one

play09:15

so

play09:15

[Music]

play09:17

and also we need to connect

play09:20

execute

play09:21

this same code so therefore

play09:26

let's do something like this

play09:32

let's convert this

play09:34

to a macro

play09:51

forward them

play09:56

and duplicate

play09:59

connect the same thing

play10:02

into accelerate custom event

play10:09

i'll just call it value

play10:14

and similarly

play10:17

uh

play10:18

done

play10:21

custom event

play10:24

turn

play10:27

i'll duplicate the same

play10:30

piece of code

play10:35

like this

play10:38

now

play10:40

we have these two

play10:44

custom events that we can use to drive

play10:46

the car

play10:48

automatically through the blueprint so

play10:52

here how

play10:55

to find

play10:57

right so

play10:59

now we need to give these two inputs

play11:02

turn

play11:03

and accelerate so to give accelerate

play11:08

without thinking about turning let's

play11:10

just

play11:11

make the car move forward

play11:14

so if i call

play11:16

[Music]

play11:17

accelerate here

play11:21

with

play11:22

maybe 0.2

play11:24

or just say 1

play11:27

don't know

play11:29

it should move forward

play11:31

and now here let me simulate

play11:35

without

play11:38

playing see now the car goes forward

play11:43

until it hit

play11:47

the wall

play11:48

so right

play11:50

now how can we define a max speed

play11:55

let's say

play12:00

40

play12:04

so we can

play12:07

get the vehicle movement component

play12:17

get forward speed

play12:22

what kind of a value do we get here

play12:29

actually we know that because

play12:32

we can find that because if i

play12:34

play the game you can see in the bottom

play12:37

left

play12:42

the speed

play12:44

the car is pushing me

play12:47

let me put

play12:49

the player car behind

play12:57

see it's

play13:00

costs around 120

play13:03

okay and the calculation is here in

play13:06

vehicle player controller

play13:08

speed

play13:10

okay if mph we have to multiply by this

play13:13

value

play13:14

if

play13:16

k and ph

play13:18

this value

play13:21

so let's consider only kmph

play13:24

and if i want to

play13:29

keep the speed under let's say 40

play13:34

we can say

play13:37

if

play13:38

this is

play13:39

less than

play13:42

40

play13:45

apply acceleration

play14:04

now the car didn't go that fast

play14:07

but still it bumps into

play14:11

a wall

play14:12

to test that

play14:17

let's make the speed even further

play14:21

let me promote this to variable

play14:24

max

play14:25

speed

play14:44

yeah i speed

play14:47

otherwise

play14:48

it could be a bit

play14:50

confusing

play14:54

it's q5

play14:56

so if i'm correct car should go really

play14:59

slow

play15:06

it doesn't look like going slow

play15:11

why

play15:17

let's print what we get here

play15:33

oh

play15:34

it says hello

play15:38

oh sorry

play15:52

two

play16:00

let's forget about this multiplication

play16:04

and put directly what we get here

play16:18

oh

play16:19

all right so actually uh when we you

play16:23

have a user input we always call this

play16:26

if we are not pressing

play16:28

forward button with zero values so maybe

play16:32

that's the case

play16:39

also we need to consider

play16:41

the absolute value

play16:51

so here

play16:54

instead of having a branch

play16:58

we can

play16:59

do a selection

play17:07

if this condition is true one otherwise

play17:10

zero

play17:22

okay

play17:25

it's not moving at all

play17:30

let's try 40

play17:34

with

play17:36

this multiplication

play17:49

right now it's moving

play17:52

not that fast okay good

play17:56

now we have a car that goes with some

play17:59

control and the next step is

play18:02

making it turn

play18:04

and this is also not

play18:06

i don't want it to be just some

play18:09

following the spline or just moving the

play18:11

car through the code along the spline

play18:14

it's that's not the way i want i want

play18:17

the ai to use the actual

play18:20

vehicle movement component and drive the

play18:22

car

play18:23

right so how can we do that

play18:28

[Music]

play18:33

from the road

play18:40

and the construction script

play18:44

oh no here

play18:50

let's convert this to a validated get

play18:56

and get spline

play19:03

promote this to variable

play19:10

rod spline

play19:22

and then

play19:24

compile

play19:27

now we should have a reference there

play19:32

in the vein graph

play19:34

so this is regarding acceleration

play19:41

let's collapse

play19:45

speed

play19:47

control

play20:05

then we need

play20:08

a way to detect

play20:10

steering

play20:11

so

play20:13

for that

play20:15

uh

play20:17

let's

play20:19

have two

play20:21

components here in the car

play20:24

like sensors

play20:27

and

play20:28

[Music]

play20:30

the mesh

play20:34

same component

play20:37

these are just

play20:38

reference reference points

play20:50

one is here

play20:52

near the left field

play21:03

i'll call it lp just left point

play21:08

and

play21:19

another one

play21:21

duplicate

play21:25

rb

play21:26

right point

play21:30

on the right side so that means plus 120

play21:34

now

play21:36

we have two reference points

play21:39

uh

play21:40

from the

play21:41

spline

play21:43

we have the spline

play21:46

let's get

play21:53

get

play21:56

location

play22:00

at distance

play22:02

along along spline and i'm going to use

play22:04

the workspace

play22:06

so

play22:07

as the distance let's promote this to a

play22:09

variable

play22:11

i'll name it target spline

play22:15

distance

play22:16

so this

play22:19

variable represents

play22:23

the

play22:23

distance along the spline that the car

play22:27

is trying to reach

play22:36

and by using these

play22:38

and these two points are defined i am

play22:41

going to

play22:42

determine

play22:44

whether the car should have a right turn

play22:46

a steering or a left steering

play22:50

right let's see how this goes and we can

play22:52

start from there

play22:57

from what

play22:58

that's from register variable

play23:01

target point

play23:10

now

play23:12

the distance from the target point

play23:16

to the call

play23:20

location by collocation

play23:24

[Music]

play23:26

detector location

play23:32

if the distance is less than

play23:38

first we need to calculate distance

play23:43

is less than let's say

play23:46

500 meters

play24:00

the branch

play24:09

we need to

play24:12

extend this distance

play24:14

so let's add another 500

play24:19

so that we can keep the car moving

play24:21

forward

play24:26

get the spline distance

play24:30

add

play24:35

ah let's promote this to variable

play24:39

let's call it

play24:42

check

play24:43

cap

play24:48

i don't have a better name for that

play24:50

at the moment

play24:55

and set it

play24:58

as the target distance

play25:01

new target distance

play25:06

if the distance is

play25:10

higher than the check gap this distance

play25:13

if it is higher than the check gap

play25:16

we don't have to do anything

play25:19

one more thing

play25:21

if

play25:22

this exceeds

play25:24

uh

play25:26

the maximum length

play25:28

of the

play25:30

spline we need to reset it back to zero

play25:34

so that

play25:35

the we can make the car continue

play25:37

in a loop

play25:39

but let's look into that part later

play25:41

for now let's just

play25:43

see if the car can continue one round

play26:08

now how to determine the distance uh the

play26:11

direction

play26:13

and we have can give steer

play26:17

what's the function name i give

play26:20

turn

play26:24

um

play26:27

shall we name this

play26:28

tear

play26:32

that seems

play26:33

more appropriate

play26:39

so how do we determine this value

play26:42

as the first attempt

play26:45

let's get the target point

play26:48

and get these two points

play26:52

get

play26:53

word

play26:56

location

play26:58

of both points

play27:10

[Music]

play27:16

and calculate distance

play27:21

to each point

play27:37

then

play27:38

if

play27:39

lp is closer to that point

play27:43

to the target point

play27:45

we should turn left if rpa is closer

play27:49

we should turn right

play27:51

right

play27:52

let's see if that works

play27:56

i'm not 100 sure to be honest

play27:59

uh

play28:00

if this one is greater

play28:03

than this one

play28:04

that means l p is

play28:09

that means rp is closer yeah

play28:14

to select float

play28:17

based on this

play28:21

plus one minus one

play28:24

maybe not

play28:26

plus one like

play28:30

0.2 let's try first

play28:35

let's try

play28:36

uh before that

play28:38

let me remove that print

play28:41

it's

play28:46

overloading the screen

play28:51

okay car is coming

play28:57

and it should turn right

play29:00

it is turning right but

play29:03

not enough

play29:06

okay

play29:08

so then

play29:11

let's try

play29:18

0.6

play29:30

the car is sort of

play29:36

shaking

play29:38

in two sides which

play29:41

we should do something to avoid that

play29:44

other than that it seems it can follow

play29:47

the spline

play29:49

let's see

play30:08

yeah it can

play30:10

and also

play30:13

right let's prevent that

play30:15

shaking to the sides

play30:17

maybe we can prevent it if i

play30:23

consider

play30:24

[Music]

play30:26

the difference amount

play30:28

let's say

play30:46

if this value is

play30:49

let's set the multiply here

play30:55

and select the multiplier

play30:58

based on this difference

play31:01

if the difference is let's say

play31:11

let's promote this to a variable

play31:15

get difference

play31:28

10.

play31:39

so if the difference is less than 10

play31:43

it's not done

play31:45

until it goes higher than 10

play31:49

if it is

play31:51

less than if it is higher than 10

play31:54

let's turn

play32:04

now it's not shaky

play32:28

still not perfect

play32:32

all right

play32:33

maybe

play32:35

okay

play32:36

there is a way to

play32:38

prevent this

play32:39

so let's promote

play32:42

this

play32:45

steering into a variable

play32:52

here

play32:56

amount

play33:01

instead of directly setting it

play33:05

let's do a lap

play33:17

use it like this

play33:22

get this dear amount initially it will

play33:24

be zero

play33:26

left

play33:29

to whatever is target amount

play33:32

with the

play33:46

we do have the delta seconds here

play33:49

so

play33:50

still delta seconds

play33:55

multiplied by i don't know

play34:01

40

play34:03

by the way i'm multiplying with delta

play34:05

seconds to keep this change rate

play34:09

con

play34:12

independent from the frame rate

play34:32

it seems working

play34:41

yeah much smoother than before

play35:06

but it's still not good

play35:14

and let's see what happens when it

play35:16

reaches the end

play35:40

one more thing well when it reached the

play35:42

end

play35:44

we should do this

play35:51

let's collapse this

play35:56

set spline

play36:00

distance

play36:12

if

play36:13

this value

play36:15

is greater than

play36:18

get the road spline

play36:21

length

play36:27

we can do a selection here

play36:33

if it is greater than

play36:35

the this

play36:36

target display and distance should be

play36:38

zero otherwise this value

play36:44

so car would be able to continuously

play36:46

follow

play36:47

and also maybe

play36:49

here

play36:55

instead of

play36:58

increasing

play37:00

oh no not there here

play37:03

check gap

play37:06

this is 500 if i reduce that i think

play37:12

ah not

play37:14

check gap

play37:20

here

play37:21

check gap here is fine

play37:24

but uh

play37:28

for here instead of check gap

play37:32

let's introduce a new variable

play37:38

distance in

play37:41

payment

play37:44

cap

play37:52

let's say 50.

play38:26

okay

play38:33

and

play38:39

yeah

play38:41

let's try decreasing this a bit

play39:01

where is the bar

play39:20

so when you reduce that

play39:24

it can't get tight corners but for this

play39:26

map it works fine

play39:33

oh not

play39:39

no

play39:40

that's not a good idea

play39:53

so let me

play39:54

change it back to

play39:58

0.6

play40:08

and let's have focus

play40:56

let's wait till they

play40:59

complete one round

play41:01

to check if they can

play41:05

continue in a loop

play41:57

yeah it seems they can continue in a

play41:59

loop without an issue

play42:03

all right

play42:06

so with that i'm going to

play42:09

finish this episode so yeah you can see

play42:12

the final demonstration

play42:16

so here i have slightly increased the

play42:18

car speed to 50 kilometers per

play42:22

hour

play42:23

rather than 40

play42:27

and this is after coin two consecutive

play42:30

rounds

play42:37

all right so thanks for watching as

play42:39

always project files will be available

play42:41

here for the download

play42:44

in the patreon page link would be in the

play42:46

description below and if you like to

play42:48

support my work

play42:49

you can get the membership of the

play42:51

patreon club see you in another episode

play42:54

goodbye

Rate This

5.0 / 5 (0 votes)

Related Tags
AI運転車自動運転ゲーム開発スプライン車両コントロールプログラミングブループリント3Dグラフィックス車両シミュレーションAIアルゴリズムテクニカルチュートリアル
Do you need a summary in English?