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"

pick up weapons from the ground (problem c++)

Hello guys. I'm trying to pick up weapons from the ground. First, play animation and then snap the root component of weapon to character socket. But if I snap the root component of weapon to socket, the weapon don't receives the correct location. If I snap only the weapon mesh, the weapon receives the correct location, but if I throw out the weapon and pick up again, weapon receives incorrect location. Somebody?

This code causes the weapon to receive incorrect position

 ACharacterMS* GetChar = Cast<ACharacterMS>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
     WeaponRootBox->SetHiddenInGame(false);
     WeaponRootBox->AttachTo(GetChar->FPVMesh, "WeaponSocket");

and this code causes the weapon to receive the correct position, but to throw it away and then take the gun back she does not receive the correct location of the socket

 ACharacterMS* GetChar = Cast<ACharacterMS>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
     WeaponMesh->SetHiddenInGame(false);
     WeaponMesh->AttachTo(GetChar->FPVMesh, "WeaponSocket");


Product Version: UE 4.10
Tags:
more ▼

asked Feb 22 '16 at 08:32 PM in C++ Programming

avatar image

CrazydevGames
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi,

USceneComponent::AttachTo takes an EAttachType as an optional parameter, after the socket name. When you are calling AttachTo on your root component, if you pass EAttachLocation::SnapToTarget as that extra argument, like so:

 WeaponRootBox->AttachTo(GetChar->FPVMesh, "WeaponSocket", EAttachLocation::SnapToTarget);

I believe the weapon should teleport to the socket.

more ▼

answered Feb 24 '16 at 10:24 PM

avatar image

Jonwood
83 2 8 16

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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