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"

Inherited capsule component placed inside ground

So I have a character blueprint and want it to be spawned through a spawner blueprint.

It now sometimes gets placed halfway into the ground and falls through. I can sense this is because the inherited capsule component goes halfway into the ground too. I can't reposition it though, because it's root / inherited.

I managed to solve this by adding the capsule's half height as a local actor offset right after spawning it, but this doesn't seem like a very clean solution. Is there a common way to deal with this?

Why is the capsules pivot point halfway into the ground anyways?

Product Version: UE 4.15
more ▼

asked Feb 17 '17 at 08:12 PM in Blueprint Scripting

avatar image

3 2 5

avatar image LordStuff Feb 17 '17 at 08:29 PM

Maybe somehow placing the whole character into another blueprint, just so I can position it so the pivot point is not exactly at half the height? -.-'

avatar image Talad Feb 20 '18 at 10:35 PM

I have the same problem, did you find a cleaner solution?

I did the half height for now by using this code:

         UObject* Object = MyCharBlueprintClass->ClassDefaultObject;
         ACharacter* Character = Cast<ACharacter>(Object); // cast to your
         float capsuleHalfHeight = Character->GetCapsuleComponent()->GetScaledCapsuleHalfHeight();

Alternative code I used previously was the one below, but the one above is simpler and achieves the same result.

         // calculate half of the capsule height
         float capsuleHalfHeight = 0;
         UBlueprintGeneratedClass* ActorBlueprintGeneratedClass = Cast<UBlueprintGeneratedClass>(MyCharBlueprintClass);
         TSet<UActorComponent*> children = MyCharBlueprint->GetComponents();
         TSet<UActorComponent*>::TIterator iterComponents = children.CreateIterator();

         while (iterComponents) {

             UActorComponent* comp = *iterComponents;

             if (comp->GetClass() == UCapsuleComponent::StaticClass())
                 // Return cast USCS node's Template into your component class and return it, data's all there
                 capsuleHalfHeight = Cast<UCapsuleComponent>(comp)->GetScaledCapsuleHalfHeight();

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

1 answer: sort voted first

You need to add the Characters' Capsule Half Height additionally to the original Spawn Location's Z.

more ▼

answered Feb 17 '17 at 09:42 PM

avatar image

512 18 37 62

avatar image LordStuff Feb 18 '17 at 10:06 PM

As I said, I am spawning the character through a blueprint, meaning it's spawned through the command "SpawnActorFromClass" or whatever it's called... So the problem is, I only have a pointer to the class, and not an object of that class.. If I only have a class, I can't access the capsule component (though it's inherited, I don't know why it's not possible...).

If I wanted to add the half height at spawn time, I'd need to spawn an actor of that class, just to read it's half height, and delete it again, so I can spawn the next character in the correct location...

I want that spawner to work with polymorphy, I tell it to spawn enemies, but I want to be able to chose whatever type of enemy it has to spawn. This is why I have to work with classes. It might be easier to make this using code, but I'm too lazy to use C++.. although I am a learned programmer :S

(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