Sunday, October 19, 2014

Pushable Object, Rotatable Object, "Reflecting Light"

Okay, I'm feeling a little behind here, but here are some things I made in Unreal 4 in the past couple of weeks.

Pushable Object


So our game is supposed to feature plants that the water gun can make grow and then act as platforms, jump pads, etc., but there is also a temple in the game. My big idea was that maybe there isn't enough light in the temple for the plant to grow, except under holes in the ceiling where light shines through.  Thing is, not all the plants are planted under shafts of light.  So how do you get the light to the plant?  With mirrors, of course!  Why are there mirrors in this temple?

...You ask too many questions, bub...

But just leaving the mirrors under the shafts of light would make things too easy!  It would be more fun (or at least time-consuming) if the players had to push the mirrors into the light.  Let's take a look at our mirror:
Okay, so it's not a mirror.  Sue me.  What matters are those boxes on either side.  At first I tried to use Blueprint to discern from what direction the player was approaching the object from, but I eventually gave up and just put boxes around the object.  Maybe that functionality exists in Unreal 4, but this should work for now.
This this is the Graph.  The thought occurs that there may be a more elegant solution than to use "Make Transform" and "Add Actor Local Transform," but it's getting kind a late and I only remember having issues with other commands (although that may have something to do with my trying to make the object both rotatable and pushable).  Anyway, you'll need one set of those for every box around the object so you can push it in any direction.  The Timeline component is to make sure the object doesn't just teleport to its destination.
 Double-click on the Timeline to open it's graph.  It'll put a little tab up there so you don't have to do that again.  Click "Add Vector Track" and it'll add a timeline here as well as a corresponding output on the component.  There'll be a red line at the bottom of the timeline, representing the X axis.  Shift+Click this to add Keyframes to the timeline, which has a "Time" variable and a "Value" variable (representing its location in this case).  You need two of these, one representing where the object is now (0 seconds and 0 distance away), and the other representing how far you want it to go and how fast.  The Value will be positive or negative depending on the direction.  There are also green and blue lines representing the Y and Z axises, respectively, for when you want the object going in those directions.  Click the eyes on the upper right of the timeline to make them visible or invisible.

Rotatable Object

Just pushing blocks too boring, you say?  How about if you had to rotate them, too!?  Well, I tried making it pushable and rotatable, but it just had a seizure when I tried to push it.  Then I put a component on it just for turning it, but turning it while it was moving made it change direction.  Might have to do with the "Local Transform" command.  I'll have to look into it.  Right now, I'm thinking it might be better to put a rotatable object on top of a separate, pushable object if you want to do both.  Might have to parent them or something.
Anywho...
 No boxes.  Doesn't really need it as long as it has collision already and you only want it to do one thing.  You'll notice that it's the same static mesh as the other object, which is why I put materials on them.
Pretty simple.  "Event Hit" allows it to trigger when hit by projectiles.  Unfortunately, it also triggers when hit by the player and I haven't figured out how to get it to differentiate between the two yet.  I tried using Timeline to make it turn gradually, but not only did it not work, but the first time I hit it caused it to continuously spin for a moment.  That's its first reaction whenever you start playing, but subsequent strikes generally responded normally.  It might be possible to get it to turn gradually, but I'll have to continue looking into it.


Reflectable Shaft of Light

I feel like I'm forgetting something... Oh, duh!  The shaft of light! Gotta reflect something, right?
Okay, it's actually a solid column.  It doesn't matter what I put in there, as long as there's a volume somewhere that will detect collisions.  This one just has a small one at the base.
You can find "OnComponentBeginOverlap" by right-clicking the component under "My Blueprints" and going to "Add Event."  The "Add Static Mesh" command is as easy as dragging the target asset into the Graph.  The Branch is there to make sure the shaft doesn't respond to the player touching it.  Make sure the Transform has the new component spawn at a different angle or location, or there'll just be two in the same place.

Want to see these Blueprints in action?  Of course you do!  TO YOUTUBE!

Using Kachujin in third person again.  I followed Marcus' "Third Person Shooter" instructions, and she looks even more gimpy.  The Mixamo characters have either shoot or throw animations, but I'll have to mess with shooting Blueprints to make it work right with them.

I'll keep you posted if I come up with more.








No comments:

Post a Comment