playMaker

Author Topic: Move npc in a sidescroller  (Read 2137 times)

PIXELCRY

  • Playmaker Newbie
  • *
  • Posts: 30
Move npc in a sidescroller
« on: November 16, 2012, 12:03:31 AM »
Hello, in my game the view is in 2d, character only need to move on X axis.

my npc only have animation data/rigidbody/colider

i only need to move them on X axis and keep them stick to the terrain with gravity

im tryin to make some AI ( i use free unity and dont have pathfinding solution) when i want them to attack my character i store character position+ a small offset in a variable (i use Get Position: he take  X,Y,Z)
 and use Move Toward action.

my problem is the follow the character on Y axis, i dont want that, i have seen constraint action for ignore axis, but i need my npc move on Y depending to the terrain!

is there a better solution?

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Re: Move npc in a sidescroller
« Reply #1 on: November 16, 2012, 04:48:41 AM »
Hi,
As a simple solution - after setting proper constraints in RigidBody (block Z movement and rotations) you can simply apply force (only X axis / every frame / world) to AI to move it in player's direction till it reach him or else.

A.
« Last Edit: November 16, 2012, 04:55:21 AM by Andrew_Raphael_Lukasik »