Hello,
I’ coming from Unity, so I haven’t done much in C++, except some Workshops, but they was only in C.
My current status is, that I can see the other “Blue Guys” walking arround etc., but the Bullets can only be seen, if the Server is spawning them.
By reading though the Forum I figured out, that the Clients will need to make a RPC to the Server, that they wanna spawn a Bullet.
Now I have read this: https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/RPCs/index.html.
So I wrote this in the Character.h(under TouchStarted):
UFUNCTION(Server,Reliable, WithValidation);
void CreateBullet(const FRotator rot, const FVector loc);
And this in the Character.cpp:
bool CreateBullet _Validate(const FRotator rot, const FVector loc) {
//I Guess here I can check, if they Delay since last shoot is over, or?
return true;
}
void CreateBullet _Implementation(const FRotator rot, const FVector loc) {
UWorld* const World = GetWorld();
if (World != NULL)
{
// spawn the projectile at the muzzle
AActor* theActor = World->SpawnActor<AMyProject2Projectile>(ProjectileClass, loc, rot);
}
}
And in the OnFire Void I wrote this:
if (ProjectileClass != NULL)
{
const FRotator SpawnRotation = GetControlRotation();
// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
const FVector SpawnLocation = GetActorLocation() + SpawnRotation.RotateVector(GunOffset);
CreateBullet(SpawnRotation, SpawnLocation);
}
...]
In the cpp the _Validate and _Implementation are red underlined as well some other Words…
If I try to build it tells me:
Fehler 1 error : In MyProject2Character: Missing event name D:\Unreal Projects\SimpleBPShooter\MyProject2\Source\MyProject2\Public\MyProject2Character.h 48 1 MyProject2
Fehler 2 error code: 2 D:\Unreal Projects\SimpleBPShooter\MyProject2\Intermediate\ProjectFiles\Error MyProject2
Line 48 is this:
UFUNCTION(Server,Reliable, WithValidation);
I don’t know if I even cast the RPG correct, cuz this is not standing in the Docs, but as it seems like the error is somewhere else…
It would be great, if you could help me :).
By the way I have Version 4.5.1