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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Pawn with subcomponents holding meshes and logic

Hi everyone,

I started porting my helicopter flight simulator to UE. I just came across some best practice issues.

My Helicopter should be of type Pawn. Next I want to add sub-components such as rotor and rotorblades. I'm a little bit confused, which type of C++ sub-component to use. I want to achieve, that each sub-component may hold a static mesh (in case of the component for rotorblades) and it's assigned logic. In this way, all logic will be part of the component that is responsible for it.

Final result should be, that a rotor is attached as subcomponent to the helicopter pawn. A rotor itself consists of multiple rotorblades attached as subcomponents to it, which should be represented by some physics and it's designated geometry.

The helicopter pawn will receive the joystick input and pass it to the sub-components for the physics calculations.

Overview:

  • Helicopter Class [Pawn]
    • Fuselage [StaticMeshComponent]

    • MainRotor
      • Rotorblade1

      • Rotorblade2

      • Rotorblade3

      • Rotorblade4

Thank you

Product Version: UE 4.19
Tags:
more ▼

asked Aug 01 '18 at 01:19 PM in C++ Programming

avatar image

semaph0r
10 1 4

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

1 answer: sort voted first

You can make your own component extending USceneComponent (which extends UActorComponent).

You can check for more suitable candidates from the links provided.

Happy coding :)


P.S.

I think you are missing the point of the component based decoupling pattern. One of the main reasons for components to even exist is to separate the gameplay logic from the mesh (rendering) and physics. This maintains "locality of reference" in order for your game to take advantage of the CPU cache.

There is a great book on Game Programming Patterns from Robert Nystrom which might provide more insight on game engine architecture.

more ▼

answered Aug 01 '18 at 02:28 PM

avatar image

dZh0
1.3k 6 5 9

avatar image semaph0r Aug 01 '18 at 03:06 PM

Thank you for your feedback. I will have a look on the book recommendation. What is your approach on where the actual behaviour should be put in to, if not into the actual component which also have some reference to the geometry?

avatar image dZh0 Aug 01 '18 at 07:13 PM

The logic should be put on an ActorComponen. ActorComponents have no transform, no mesh and are not really a part of the hierarchy (other than belonging to a pawn). They are pure logic.

However, only common logic should go there. There is no point in having an unique component. They should be reused by all your helicopters no matter how different they are and this makes those components quite hard to design.

My approach would be to have a large part (including the rotors and blades) of my helicopter as a skeletal mesh parented to a collider. I'll put only the parts that can be changed during gameplay on different components and attach them to sockets on my main body mesh. (like weapons or destructible parts)

I would create a Helicopter Movement component to handle all the physics and flight dynamics. It should hold a reference to the mesh and dictate the rotors' speed and the blades' angle of attack through animations. (similar to how the character movement component works in the templates)

I would probably have another Actor Component which handles the weapons and how they fire, how many ammunition they have and all the logic in them.

These component (movement and weapons) would be replicated on the network because although I don't care weather the enemy player's helicopter blades have the correct angle I need to make sure that their helicopter position and the position of their rockets is as close to uniform as possible for all players.

That being said you can also make those Actor Components create or change some of the meshes (weapons for instance) based on player choice or damage taken. You can also make the Movement component spawn a dust particle emitter beneath the helicopter when it flies too low to dusty ground.

I really hope this helps you.

Happy coding :)

avatar image semaph0r Aug 04 '18 at 11:39 AM

Thank you very much. I appreciate your help a lot. The last part regarding the dust particle emitter is one feature I have on my todo-list.

(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