No announcement yet.

Rotating Ship

  • Filter
  • Time
  • Show
Clear All
new posts

    Rotating Ship

    Hello Everyone,

    I am basically trying to figure out a way to rotate my spaceship using the mouse and gamestick controls, I essentially want the same effect as Geometry wars has but instead of the cannon moving I would like for the ship to face the direction I just have no idea how to set this up I have my Axis setup and mapped it out in blueprints but was wondering how to do so in code...

    Not sure if that's right or wrong?

    Last edited by Kevin.Soares7; 04-29-2014, 07:41 PM.

    I'm trying to do something similar to this, but I'm after a 3D pilotable vehicle. I'm some ways in already, and I'll hopefully be able to fill in more of Rama's Custom Charatcer Movement Component tutorial after the weekend, which might even include some fun about the Player Controller.

    Kevin, I'm going to throw a bunch of code references at you because I'm in at work and can't see my own code, but try your best, you might get somewhere. I'm coming from this from the perspective of 1st Person Shooter, so excuse me if your code isn't quite like this, but hopefully this will help.

    APlayerController (/Engine/Source/Runtime/Engine/Private/PlayerController.cpp) is essentially the class you are controlling; it's like your soul floating in the aether that is your game world. APlayerController can then possess Pawns inside the world to gain control of them and do fun things (try to resist the urge to recreate Messiah).

    APlayerController::InitInputSystem is called in the early days to set up the UPlayerInput class, which actually handles all your inputs. Unlike UDK, we don't want to handle all your inputs on PlayerController because that would mean all your pawns become dependent on APlayerController to feed them the inputs. That's a great way to end up with a mammoth PlayerController with a bazillion input conditions (am i walking, running, swimming, driving, user a glider, piloting a plane, blah blah blah). Instead, UPlayerInput will be passed to the Pawn you're possessing, and give the pawn the opportunity to read your inputs.

    Now, if you check out your MyProjectNameCharacter (you've probably got one), you should find a function like SetupPlayerInputComponent() which has a list of inputs being initialised within it. These refer to plain text names like what you've got in your screenshot, for MoveForward, Rotate, etc.
    These basically setup callback functions (the last? argument) which mean when you're possessing that pawn, your input component will trigger those functions on this object.

    From here, it's simply a matter of making new functions for, say, MoveForward, and applying the impulses to the Pawn itself, which can be accessed by:
    APawn* const P = GetPawnOrSpectator();

    That's all I can help you with until I can get back in front of an actual project.

    Now, in my case I want to possess another Pawn as a vehicle, have my old pawn "get in" the new vehicle, and have my inputs go to a Movement Component on the vehicle itself. Note that you don't need the movement component, it's perfectly possible/OK/the-tutorials-do-it to simply put the impulses directly onto your possessed pawn. Movement Component is intended to separate complex logic (am i swimming, standing, in a bog, have no kneecaps etc) from the rest of the pawn code, which probably doesn't care about any of that stuff.

    If you get to adding pickups that affect your speed, then maybe Movement Component is the way to go, but hopefully by then I'll have documented how to do it anyway