请问如何用C++控制static mesh的旋转呢?
如图,我用蓝图能够实现这个功能,那么如何改写成C++版本呢?1. 首先你得将两个旋转的静态组件作为成员变量声明在你的C++类中(如:AMyPawn)
2. 重写 void AMyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent) 进行输入绑定,如
InputComponent->BindAxis("LookRight", this, &AMyPawn::AddControllerYawInput);
InputComponent->BindAxis("LookUp", this, &AMyPawn::AddControllerPitchInput);
3.在自定义的 AddControllerYawInput() 、 AddControllerPitchInput() 调静态组件的 AddLocalRotation()
以上只是说思路,具体代码自己整理吧 Someday 发表于 2016-7-17 22:35
1. 首先你得将两个旋转的静态组件作为成员变量声明在你的C++类中(如:AMyPawn)
2. 重写 void AMyPawn::Se ...
谢谢版主!成员变量声明和定义这些已经在C++中做好了,然后调用蓝图的,操控static mesh可惜还不会用C++,我看了官方的Character和Vehicle,他们的左右旋转是这样的:
//人物
void AProjectileCharacter::TurnAtRate(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}
//车辆
void AMyProjectPawn::MoveRight(float Val)
{
GetVehicleMovementComponent()->SetSteeringInput(Val);
}
那么我的场景中有两个static mesh对象Vehicle_Turret和Vehicle_Barrel,怎么才能获得具体对象的操作权呢?就是类似于GetVehicleMovementComponent()和GetWorld()的东西?
页:
[1]