Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6031161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:08:33+00:00 2026-05-23T05:08:33+00:00

OK it’s a general question, just how the system of my game should work.

  • 0

OK it’s a general question, just how the system of my game should work.
So there are lots of enemies and a player. When a enemy touch a player, the player gets a hit and a “push” from the monster, and then blinks to 1.5 seconds. Wile the “push” (really really fast), the player can’t do nothing.
Also, all the monsters will always move the same. The move of the monsters will never be affected by the player. I can’t do it kinematic because they DO affect from the gravity. So how can I do that? All that thing, include the “push”, what should I do?

There’s also a good example for what I mean in this YT video from 0:27 : http://www.youtube.com/watch?v=tVr8S6WXdog

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:08:34+00:00Added an answer on May 23, 2026 at 5:08 am

    With your example I’m presuming that you don’t plan on actually having the monster and humans reacting to one another.

    Either way, add a custom contact listener to the world and within the contact listener check if a player and a enemy shape create a contact point. If so applylinearimpulse() to the playerbody to the effect that you would like and disable all key input from the user to prevent any change in motion. Then just have a property on player preventing it from applying the impulse if its just been hit by the monster.

    Also when you create the bodies you’ll need to set the player and enemy instance as the body.UserData()

    public class Player extends MovieClip
    {
         public const MAX_EFFECT_TIME = 1.5 * framerate;
    
         public var effectTime:int = 0;
         public var body:b2Body;
    
     public function step():void
     {
           if (effectTime > 0)
           {
                  effectTime--;
                  //do awesome animation
           }
           else 
           {  
                  //move normally
           }
    
     }
    
     public function Hit(enemy:Enemy)
     {
           if (effectTime == 0)
           {
                  //apply linear impulse to object
                  if (enemy.body.GetPosition().x < this.body.GetPosition().x)
                  {
                        //apply impulse left in left direction
                        b2Vec2 force = b2Vec2(-8, 10);
    
                        body.ApplyLinearImpulse(force, body.GetWorldCenter());
                  }
                  else
                  {
                        //apply impulse in right direction
                        b2Vec2 force = b2Vec2(8, 10);
    
                        body.ApplyLinearImpulse(force, body.GetWorldCenter());
                  } 
    
                  //reset effect time
                  effectTime = MAX_EFFECT_TIME;
           }
     }
    

    }

    public class Game extends MovieClip
    {
          public var world:b2World;
          public var player:Player;
    
          public Game()
          {
                world = initWorld();
                player = initPlayer();
    
                var cl = new CustomContactListener();
                world.SetContactListener(cl);
    
                this.addEventListener(Event.ENTER_FRAME, step);
          }
    
          private void step(e:Event)
          {
                world.step();
                player.step();
          }
    

    }

    public class CustomContactListener extends b2ContactListener
    {
          //Called when a contact point is added.
          public override function Add(point:b2ContactPoint):void 
          {
                //checks if the first shape is a player and second is an enemy if true call Hit
                if (point.shape1.GetBody().GetUserData().isPlayer && point.shape2.GetBody().GetUserData().isEnemy)
                {
                     point.shape1.GetBody().GetUserData().Hit(point.shape2.GetBody().GetUserData());
                }
                else if (point.shape2.GetBody().GetUserData().isPlayer && point.shape1.GetBody().GetUserData().isEnemy)
                {
                     point.shape2.GetBody().GetUserData().Hit(point.shape1.GetBody().GetUserData());
    
    
          }
          }
    }
    

    Then you can just edit values as necessary. Hope this helps and good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.