Announcement

Collapse
No announcement yet.

Add an Impulse in the right direction...( Side scroller game)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Add an Impulse in the right direction...( Side scroller game)

    Hi guys i have a little problem, i made this simple movement script, If Pg Damage Boolean is false you can move, If Pg Damage Boolean is true you receive an impulse that push you back( X - 25000), so if you arrive from the left side everything its ok, you overlap the Enemy pawn and the boolean became true, but if you arrive from the right side you will be pushed in the wrong size How i can fix that issue ? I want that if you arrive from the right side you will be pushed in X 25.000. There is an "Enemy" in the middle that follow the player. Thank you.

    #2
    If you want to be pushed away from an enemy that you have overlapped, you need to get the enemy's location and subtract it by your character's location. Normalize the resulting vector, multiply it by 25,000, and plug that into your Add Impulse node.

    If you want to constrain it to the horizontal plane, you can break the subtracted vector and drag the x pin into a make vector, which is then plugged into the normalize node before being multiplied.
    Last edited by ausernottaken; 01-04-2018, 06:12 PM.

    Comment


      #3
      Originally posted by ausernottaken View Post
      If you want to be pushed away from an enemy that you have overlapped, you need to get the enemy's location and subtract it by your character's location. Normalize the resulting vector, multiply it by 25,000, and plug that into your Add Impulse node.

      If you want to constrain it to the horizontal plane, you can break the subtracted vector and drag the x pin into a make vector, which is then plugged into the normalize node before being multiplied.
      Thank you I try now

      Comment


        #4
        Originally posted by ausernottaken View Post
        If you want to be pushed away from an enemy that you have overlapped, you need to get the enemy's location and subtract it by your character's location. Normalize the resulting vector, multiply it by 25,000, and plug that into your Add Impulse node.

        If you want to constrain it to the horizontal plane, you can break the subtracted vector and drag the x pin into a make vector, which is then plugged into the normalize node before being multiplied.
        I try this, But now the player is pushed in the position, like if the result was 0

        Comment


          #5
          Your Add Impulse function needs to be entirely separate from your input event. Instead, add in an On Begin Overlap event from your collision component, get the overlapped actor from the hit struct and use the position of that actor for your calculations.

          Comment

          Working...
          X