Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Character Plugin
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Unreal-Development
Plugins
Character Plugin
Commits
5d0f6c91
Commit
5d0f6c91
authored
4 months ago
by
Konstantin Kühlem
Browse files
Options
Downloads
Patches
Plain Diff
feat(VirtualHuman): Add BlueprintCallable method to force a reselect of the IDLE animation
parent
c8e4bd89
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/CharacterPlugin/Private/VirtualHuman.cpp
+14
-5
14 additions, 5 deletions
Source/CharacterPlugin/Private/VirtualHuman.cpp
Source/CharacterPlugin/Public/VirtualHuman.h
+11
-2
11 additions, 2 deletions
Source/CharacterPlugin/Public/VirtualHuman.h
with
25 additions
and
7 deletions
Source/CharacterPlugin/Private/VirtualHuman.cpp
+
14
−
5
View file @
5d0f6c91
...
...
@@ -168,6 +168,16 @@ bool AVirtualHuman::SupportsMorphs()
return
BodyType
!=
EBodyType
::
MetaHuman
;
}
bool
AVirtualHuman
::
ForcePlayNewIdleAnimation
()
{
if
(
CustomIdleAnimations
.
IsEmpty
())
return
false
;
NextIdleTimerHandle
.
Invalidate
();
PlayRandomIdleAnimation
();
return
true
;
}
void
AVirtualHuman
::
SetUpBodyType
()
{
if
(
BodyType
==
EBodyType
::
CC3
)
...
...
@@ -315,12 +325,11 @@ void AVirtualHuman::PlayRandomIdleAnimation()
}
// play random idle animation
int
Random
=
IdleRandomStream
.
RandRange
(
0
,
CustomIdleAnimations
.
Num
()
-
1
);
UAnimSequence
*
IdleAnim
=
CustomIdleAnimations
[
Random
];
if
(
IdleAnim
)
const
int
Random
=
IdleRandomStream
.
RandRange
(
0
,
CustomIdleAnimations
.
Num
()
-
1
);
if
(
UAnimSequence
*
IdleAnim
=
CustomIdleAnimations
[
Random
])
{
float
BlendTime
=
0.25f
;
UAnimMontage
*
DynamicMontage
=
GetBodyAnimInstance
()
->
PlaySlotAnimationAsDynamicMontage
(
const
float
BlendTime
=
0.25f
;
const
UAnimMontage
*
DynamicMontage
=
GetBodyAnimInstance
()
->
PlaySlotAnimationAsDynamicMontage
(
IdleAnim
,
"CustomIdleSlot"
,
BlendTime
,
BlendTime
);
// start timer for next random pick (make it a bit shorter to allow for blending, but only by a defined minimal amount for the animations)
GetWorld
()
->
GetTimerManager
().
SetTimer
(
NextIdleTimerHandle
,
this
,
&
AVirtualHuman
::
PlayRandomIdleAnimation
,
...
...
This diff is collapsed.
Click to expand it.
Source/CharacterPlugin/Public/VirtualHuman.h
+
11
−
2
View file @
5d0f6c91
...
...
@@ -96,6 +96,15 @@ public:
virtual
EVHGender
GetGender
();
virtual
bool
SupportsMorphs
();
/**
* Forces a new IDLE animation to be played, which is randomly chosen from "CustomIdleAnimations".
* Note that the new animation might also be the one which is currently playing.
* This method is useful, e.g. if the "CustomIdleAnimations" change.
* @return true, if a animation was select (might be false, if "CustomIdleAnimations" is empty)
*/
UFUNCTION
(
BlueprintCallable
)
bool
ForcePlayNewIdleAnimation
();
protected:
// Called when the game starts or when spawned
virtual
void
BeginPlay
()
override
;
...
...
@@ -112,11 +121,11 @@ protected:
UPROPERTY
(
EditAnywhere
,
meta
=
(
EditCondition
=
"BodyType==BodyType::MetaHuman"
))
TSubclassOf
<
UVHAnimInstance
>
FaceAnimInstanceToUse
;
//custom idle animations can be specified to be used (played in the Def
u
altSlot)
//custom idle animations can be specified to be used (played in the Defa
u
ltSlot)
//CAUTION: this currently does not work together with walking or pointing
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"VirtualHuman|Custom Idle Animations"
)
TArray
<
UAnimSequence
*>
CustomIdleAnimations
;
//The minimal percentage of the animation that is allowed to be skiped to blend into another animation
//The minimal percentage of the animation that is allowed to be skip
p
ed to blend into another animation
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"VirtualHuman|Custom Idle Animations"
)
float
MinBlendTime
=
1.0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment