Hello so i want to make camera move when you walk / run in-game.
And i found the UCameraShake:: classs.
And it has one meber called UCameraShake::Anim of type UCameraAnim:: .
And am wondering where do i create a Camera Animation is it like a Sound Cue created in the editor?
Do someone have experience with this or can point me in the right direction?
Thanks.
ZeJudge
(ZeJudge)
July 8, 2014, 8:42am
2
Camera shakes are awesome.
In your character class I’d put something like this:
.h:
UPROPERTY(EditDefaultsOnly, Category=Effects)
TSubclassOf<UCameraShake> WalkingCameraShake;
You can now create a new Camera Shake blueprint in the editor and assign it to the above property in your character class defaults!
Create a condition in your character class finding if your currently moving, on the ground and pressing a direction key then:
.cpp:
START THE CAMERA SHAKE:
// Execute the walking bob effects
if(Controller)
{
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
if(PC)
{
if(WalkingCameraShake)
{
if(!bCurrentlyWalkingBob)
{
PC->ClientPlayCameraShake(WalkingCameraShake, 1, ECameraAnimPlaySpace::CameraLocal, FRotator(0,0,0));
}
}
}
}
STOP THE CAMERA SHAKE:
// Stop the walking bob effects
if(Controller)
{
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
if(PC)
{
if(WalkingCameraShake)
{
PC->ClientStopCameraShake(WalkingCameraShake);
}
}
}
I hope this helps!
Jon
It most certainly do.
Thank you so much.
EDit: So [FONT=Arial Narrow]TSubclassOf<class T> MemberName;
Is the way to add a Blueprint to a class?
ZeJudge
(ZeJudge)
July 8, 2014, 6:10pm
4
Thats right, this is how its displayed in my character class blueprint’s default menu:
Then I can select the camera shake blueprint that I made from my content browser.
Jon
Awsome! I did this and it works sort of.
Am having a hard time figuring out the settings for the Camera Shake.
Did you do something more then just create a new Blueprint from UCameraShake:: and set the propertys available?
Edit: Reading your code again i see you are checking if the the Walking shake is set and played.
I did not do that so am guessing this is cousing the vierd behavior, going to test that now.
ZeJudge
(ZeJudge)
July 9, 2014, 9:54am
6
Awsome! I did this and it works sort of.
Am having a hard time figuring out the settings for the Camera Shake.
Did you do something more then just create a new Blueprint from UCameraShake:: and set the propertys available?
Edit: Reading your code again i see you are checking if the the Walking shake is set and played.
I did not do that so am guessing this is cousing the vierd behavior, going to test that now.
Glad you have it working!
I had to play and tweak with the camera shake settings for quite a while to get the desired effect.
Also ensure you put conditions in your code to ensure it’s not continuously starting over/pressing play whilst walking such as:
if(!bCurrentlyWalkingBob)
{
PC->ClientPlayCameraShake(WalkingCameraShake, 1, ECameraAnimPlaySpace::CameraLocal, FRotator(0,0,0));
bCurrentlyWalkingBob = true;
}
Jon
_neo
(_neo_)
January 19, 2015, 9:55pm
7
Hello,
I having the problem that the CameraShake is always null, any idea why?
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Camera)
TSubclassOf<UCameraShake> FireCameraShake;
if (FireCameraShake) { // Always null
EDIT: Silly me, it is working now.