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"

Should I create a new MovementMode for stunning a character?

My question is two parts: Should I use a custom MovementMode called "Stunned" for example if I want to make a character unable to move (set its max speed to 0)? And if so, how do I create a custom movement mode?

Thank you!

Product Version: Not Selected
Tags:
more ▼

asked Feb 08 '15 at 10:40 PM in Blueprint Scripting

avatar image

timetravel
78 27 28 38

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

1 answer: sort voted first

Creating a custom MovementComponent will help you refine your implementation, I use a custom one for a 2D/3D point'n click adventure game to handle rotation a bit different, so yes using a movement component will help you. The bad thing is that you have to study carefully how the base MovementComponents is build to be able to adapt it to your needs.

C++ work (if you want to got that route)

The task to add you own MovementComponent will require creating a new C++ class that inherits from say UCharacterMovementComponent and a special class for you character that inherits from ACharater. You need a new base C++ class for you pawn to be able to override the existing MovementComponent of ACharacter. The following code is an base example on how you classes should look like:

 //
 // MyMovementComponent.h
 //
 
 #include "MyMovementComponent.generated.h"
 
 UCLASS()
 class MYGAME_API UMyMovementComponent : public UCharacterMovementComponent
 {
     GENERATED_BODY()
 
     // Add your custom members and functions here
 }
 
 //
 // MyMovementComponent.cpp
 //
 
 #include "MyMovementComponent.h"
 
 // You code goes in the CPP file, our base class is just empty
 

Once you have a working MovementComponent we have to tell our character to use it:

 //
 // MyCharacter.h
 //
 
 #include "MyCharacter.generated.h"
 
 UCLASS()
 class MYGAME_API AMyCharacter : public ACharacter
 {
     GENERATED_BODY()
 
 public:
     /**
     * Default UObject constructor. We need this one to override the
     * MovementComponent
     */
     AMyCharacter(const FObjectInitializer& ObjectInitializer);
 }
 
 //
 // MyCharacter.cpp
 //
 
 #include "MyCharacter.h"
 #include "MyMovementComponent.h"
 
 /**
 * Default UObject constructor.We need this one to override the
 * MovementComponent
 */
 AMyCharacter::AMyCharacter(const FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer.SetDefaultSubobjectClass<UMyMovementComponent>(ACharacter::CharacterMovementComponentName)) 
 {
     // As you can see we use 'SetDefaultSubobjectClass' to override the class that will be used for our MovementComponent
 }

With this steps you will be able to control the movement of your character the best way. On how you implement the stun logic and at the end any state related handling is totally up to you.

What about Blueprint?

If you would like to only block the player movement or input from BluePrint you can 'Set Ignore Movement Input' and 'Set Ignore Look Input' from your PlayerController.

Hope I could help you out!

Cheers, Moss

more ▼

answered Feb 09 '15 at 12:20 AM

avatar image

Moss
6.4k 127 99 607

avatar image timetravel Feb 09 '15 at 01:49 AM

Wow this is great! So I assume it's not really possible to create a new MovementMode inside the editor or in blueprints? Your suggestion of nodes to use sounds like they would do the trick though.

This is still good to know how to implement them in C++ as I plan on transitionning to C++ in the near future.

(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