x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Projectile replicates at wrong location

Hi,

I've created a player and projectile classes using First Person Shooter C++ Tutorial. I've also created an RPC function to handle projectile spawning on the server. The projectile and its movement is replicated.

The problem is that the client projectile is "shifted". It spawns at the side of the player instead of the center. The other thing is that when I shoot the other player the projectile bounces off about 1-2 meters before that player. Everything works fine on the server though (projectiles are spawned in the center and the collisions work fine).

The spawning function:

void AFPSCharacter::ServerOnFire_Implementation(FRotator Rotation) {

 if (ProjectileClass != NULL)
 {
     FVector const MuzzleLocation = GetActorLocation() + FRotationMatrix(Rotation).TransformVector(MuzzleOffset);
     FRotator MuzzleRotation = Rotation;
     MuzzleRotation.Pitch += 10.0f;
     UWorld* const World = GetWorld();
     if (World)
     {
         FActorSpawnParameters SpawnParams;
         SpawnParams.Owner = this;
         SpawnParams.Instigator = Instigator;
         AFPSProjectile* const Projectile = World->SpawnActor<AFPSProjectile>(ProjectileClass, MuzzleLocation, MuzzleRotation, SpawnParams);
         if (!Projectile)
             return;

         FVector const LaunchDir = MuzzleRotation.Vector();
         Projectile->InitVelocity(LaunchDir);
     }
 }

}

Does anyone know why is this happening?

Product Version: Not Selected
Tags:
more ▼

asked Apr 30 '15 at 09:46 PM in C++ Programming

avatar image

Robcio3
6 1 1

avatar image Dhee9000 Apr 17 '17 at 02:39 PM

I have this same exact problem. Were you able to find a solution?

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Try adjusting muzzleoffset in your instance.

It's possible the projectile is colliding with the character collision component instead of the mesh.

more ▼

answered Apr 30 '15 at 10:03 PM

avatar image

mikepurvis
2.5k 100 65 260

avatar image Robcio3 May 02 '15 at 09:16 AM

The muzzleoffset is fine. Projectiles spawned in the server work just fine, the problem is with the client only.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question