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"

Move NPC actor on spline

I am having an issue trying to move an NPC along a spline and be interrupted by the player. For example, if pawn sensing detects the player, then it should move on a positive direction on the spline. If the character moves in front of the NPC, then it should move in the opposite direction. The NPC is a Character Blueprint and I'm trying to use Simple Move to get it to move. Any insight?

Product Version: Not Selected
Tags:
more ▼

asked Feb 03 '15 at 12:51 AM in Blueprint Scripting

avatar image

specsowl
2 1 2 4

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

1 answer: sort voted first

Here's how I did it for one of my games. Direction is a float either 1 or -1 depending on if it's moving up or down the spline. I do some extra fancy stuff with Roll in my game you can probably ignore. I also RInterp the rotations which you might not need. I basically call this in the NPCs event tick passing in the delta time.

alt text

move_on_spline.png (298.0 kB)
more ▼

answered Feb 03 '15 at 01:51 AM

avatar image

Furroy
696 26 86 62

avatar image specsowl Feb 03 '15 at 11:57 AM

Thanks! I'm trying it out now. My question is what is the Set Sanitized Distance? I think it's causing an issue because my NPC only spins in circles if it's false and does nothing if it's true.

avatar image Furroy Feb 03 '15 at 12:47 PM

Set Sanitized Distance basically calls "Set Distance" but has a bunch of other messy stuff in there to deal with what happens on an open vs closed spline. How it should wrap around or just stop when it hits an open end.

avatar image specsowl Feb 03 '15 at 12:50 PM

Ok. I still can't seem to get my NPC to move along the spline though. It just rotates at the beginning. I don't have a set distance node because I'm not sure how to calculate that along the spline.

avatar image Furroy Feb 03 '15 at 01:08 PM

"Set Distance" is just the setter for the distance variable. You need a variable to track how far along the spline it is.

Here is the part of my Event Tick that would call this. You will need your Input Events to raise/lower the speed variable. Those are super complicated in my game, so the BPs are really hairy.

alt text

spline2.png (68.2 kB)
avatar image Henrique May 15 '15 at 05:49 AM

Hi Furroy, if you have a closed spline, how do you make the character continue move, i tried set 0 to distance but it didn't work?

(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