I want to have a smooth change from Lerp(Linear) to SmootherStep() by an extra parameter (,,,x).

SmootherDynamic(0, 1, 0.25, 0) should results like linear function like Lerp() = 0.25

SmootherDynamic(0, 1, 0.25, 1) should results as SmootherStep() = 0.15625

The GetPointOnBezierCurve(p1, p2, p3, p4, t) describes the shortest way between the given points based on a linear lerp(). But in some cases I’d like to have a “longer way” between these given parameter p1, p2, p3, p4, BUT without changing the parameter p1, p2, p3, p4 itself.

For example: This is exactly the difference between x=0.003 Michael Schumacher on the perfect way and other more bad drivers following the static Bezier way points x=0.0156.

So, I want to have a smooth change from Lerp(Linear) to SmootherStep() by an extra parameter.

]]>The

The lerp, however, expects values in range

Also, what exactly are you using the SmootherStep function for?

EDIT: Actually, nevermind! It’s in range [0, 1], I am talking total nonsense.

]]>cool stuff! Thank you.

I’m having a problem similar to Bezier curves. I require a dynamic function that calculate from Linear to SmootherStep. The linear is MathF.Lerp(a,b,t) and the SmootherLerp()

float SmootherStep(a, b, t) {

t = t * t * t * (t * (6 * t – 15) + 10);

return lerp(a, b, t);

}

The new function , call it maybe SmootherDynamic(a,b,t,n), should interpolate from Linear to the SmootherLerp() by parameter n. I have reworked this to:

float SmootherDynamic(p0, p3, t, x) {

x = (1 – x) * (p3 * (1.0 / 3.0));

var p1 = x;

var p2 = p3 – x;

var a = lerp(p0, p1, t);

var b = lerp(p1, p2, t);

var c = lerp(p2, p3, t);

var d = lerp(a, b, t);

var e = lerp(b, c, t);

var pointOnCurve = lerp(d, e, t);

return pointOnCurve;

}

If n > 1 (max 2) the result starts to badly override. I would like to have something like this:

https://forum.unity.com/attachments/c-3st7cxcaehfbe-jpg.277611/

Any ideas about? I want to use it for splines, but they should not override.

Thanks and regards, Roger

]]>That is, 0.2f normalisedTime is equidistant from 0.3f normalisedTime as 0.0f is from 0.1f normalisedTime.

]]>I’m using your CubicBezierCurve scripts but I’ve come across a problem. You see, I’m using these scripts to make camera rails, for cutscenes and also for corridors that follow the player.

The problem I’ve come across is that the normalisedTime on the curve slows down as it approaches the end points. Similarly, when the handles are zero’d out (x = 0, y = 0, z = 0) every point along the curve causes the normalisedTime to slow drastically as it reaches its point.

My grasp of mathematics is very flimsy to say the least, so I’m struggling to find a way to re-create your scripts without this slowing and accelerating problem.

Any help would be very much appreciated as I’m seriously stuck for solutions…

Thank you!

]]>I’ve tried C++ code. Let me share it in the case of anybody interested.

It looks like the following:

Teams ids defines:

// team ids

#define PTG_TEAM_ID_PLAYER 0

#define PTG_TEAM_ID_ENEMY 1

Enemy AI controller class implementation:

UCLASS()

class PTG_API APTGAIControllerEnemy : public AAIController

{

// ...;

```
```private:

FGenericTeamId GetGenericTeamId() const override;

UFUNCTION()

void OnPerceptionUpdated(TArray actors);

` UPROPERTY()`

UAISenseConfig_Sight* SightConfig;

};

APTGAIControllerEnemy::APTGAIControllerEnemy()

{

SightConfig = CreateDefaultSubobject(TEXT("SightConf"));

```
``` PerceptionComponent = CreateDefaultSubobject(TEXT("Perception"));

PerceptionComponent->ConfigureSense(*SightConfig);

PerceptionComponent->SetDominantSense(SightConfig->GetSenseImplementation());

PerceptionComponent->OnPerceptionUpdated.AddDynamic(this, &APTGAIControllerEnemy::OnPerceptionUpdated);

}

void APTGAIControllerEnemy::OnPerceptionUpdated(TArray actors)

{

UE_LOG(LogPTG, Error, TEXT("perception updated"));

}

`FGenericTeamId APTGAIControllerEnemy::GetGenericTeamId() const`

{

return PTG_TEAM_ID_ENEMY;

}

Player character class implementation:

UCLASS(Blueprintable)

class APTGCharacter

: public ACharacter

, public IGenericTeamAgentInterface

{

// ...;

```
```private:

FGenericTeamId GetGenericTeamId() const override;

` UPROPERTY()`

class UAIPerceptionStimuliSourceComponent* AIPerceptionStimuliSource;

};

APTGCharacter::APTGCharacter()

{

// ...;

AIPerceptionStimuliSource = CreateDefaultSubobject(TEXT("PercSS"));

AIPerceptionStimuliSource->RegisterForSense(UAISense_Sight::StaticClass());

}

```
```

`FGenericTeamId APTGCharacterBase::GetGenericTeamId() const`

{

return PTG_TEAM_ID_PLAYER;

}

I did this in 4.15, maybe they changed something. Try in BeginPlay() or something. ]]>