SHARE
TWEET

movem.cpp from unreal engine

a guest Feb 22nd, 2019 67 in 272 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #include "movem.h"
  4. #include "GameFramework/Actor.h"
  5. #include "GameFramework/Pawn.h"
  6. #include "Components/InputComponent.h"
  7. #include "GameFramework/InputSettings.h"
  8. #include "Components/StaticMeshComponent.h"
  9.  
  10. // Sets default values for this component's properties
  11. Umovem::Umovem()
  12. {
  13.     // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
  14.     // off to improve performance if you don't need them.
  15.     PrimaryComponentTick.bCanEverTick = true;
  16.  
  17.     // ...
  18. }
  19.  
  20.  
  21. // Called when the game starts
  22. void Umovem::BeginPlay()
  23. {
  24.     Super::BeginPlay();
  25.    
  26.     // ...
  27.    
  28. }
  29.  
  30.  
  31. // Called every frame
  32. void Umovem::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
  33. {
  34.     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
  35.     check(InputComponent);
  36.     InputComponent->BindAxis("MoveX", this, &Umovem::Move);
  37.     if(!CurrVel.IsZero())
  38.     {
  39.         FVector ne;
  40.         ne = GetActorLocation() + ( CurrVel * DeltaTime);
  41.         SetActorLocation(ne);
  42.     }
  43. }
  44. void Umovem::Move(float Val)
  45. {
  46.     CurrVel.X= FMath::Clamp<float>(Val, -1.0f, 1.0f) * 100;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top