ShiVa3D
Enemy's Movement? [SOLVED]
You feel lost? You don't understand how to use ShiVa?Enemy's Movement? [SOLVED]
by CrazyPenguin » 27 Apr 2012, 03:36
I am ShiVa3D Newbie,please advise.
I donot know how to write lua code to realize GridMovement. similar to the chess game.I have tried all different ways.
Have A Few Questions.
1) ShiVa3D navigation. if you does not use it, A* PathFinding, can you achieve it?
scene objects use collider,dynamics.
I also found a new function,
SHIVA 3D 1.9.1 Basic Edition
bYes = navigation.isNodeInUse ( hScene, hNode )
* navigation extra processing overhead, some android platform auto quit game. Maybe I should not consider the low-end users.
I donot know if it is a right choice.
2) second time, no navigation, scene objects use Sensor, Maybe add the dynamics, There are a lot of collider obstacles, but I dont know how to A* PathFinding.
The Enemy's AI Example code.
The 360 rotating Enemys, use Ray Find Path? little stupid. -_-
I hope that together we can discuss ways, thank a lot.
I donot know how to write lua code to realize GridMovement. similar to the chess game.I have tried all different ways.
Have A Few Questions.
1) ShiVa3D navigation. if you does not use it, A* PathFinding, can you achieve it?
scene objects use collider,dynamics.
I also found a new function,
SHIVA 3D 1.9.1 Basic Edition
bYes = navigation.isNodeInUse ( hScene, hNode )
* navigation extra processing overhead, some android platform auto quit game. Maybe I should not consider the low-end users.
I donot know if it is a right choice.
2) second time, no navigation, scene objects use Sensor, Maybe add the dynamics, There are a lot of collider obstacles, but I dont know how to A* PathFinding.
The Enemy's AI Example code.
- Code: Select all
if ( collider )
then
local Ex, Ey, Ez = object.getTranslation ( collider, object.kGlobalSpace )
local Dx, Dy, Dz = object.getDirection ( player, object.kGlobalSpace )
object.lookAt ( player, Ex, 0, Ez , object.kGlobalSpace, 0.5 )
local nDist = object.getDistanceToObject ( player, collider )
if ( nDist < 2 )
then
this.sendStateChange ( "Find" )
else
this.sendStateChange ( "Walk" )
end
end
The 360 rotating Enemys, use Ray Find Path? little stupid. -_-
I hope that together we can discuss ways, thank a lot.
ShiVa Basic Edition 1.9.1.0
Samsung Galaxy Nexus I9250 Android 4.0.2
Custom 3D : caijian9400@gmail.com
Samsung Galaxy Nexus I9250 Android 4.0.2
Custom 3D : caijian9400@gmail.com
-

CrazyPenguin - Fresh Boarder

- Posts: 13
Re: Enemy's Movement?
by DarkSoul » 27 Apr 2012, 08:26
I donot know how to write lua code to realize GridMovement. similar to the chess game.I have tried all different ways.
Use "object.Translation()" for make it. For example:
- Code: Select all
--First, you need to save the current object position
local x, y, z = object.getTranslation(this.getObject(), object.kGlobalSpace)
object.Translation(this.getObject(), x, y, z + 10, object.kGlobalSpace)
You need to use the current position and add to it the movement, for instance: "z + 10"
1) ShiVa3D navigation. if you does not use it, A* PathFinding, can you achieve it?
scene objects use collider,dynamics.
I don't know if I understand your question. If it is that you can create your own pathfinding, yes, you can, but I recommend you C++ for make it, anyway you can use the current navMesh of Shiva, I move over six characters on android with good frame rate.
2) second time, no navigation, scene objects use Sensor, Maybe add the dynamics, There are a lot of collider obstacles, but I dont know how to A* PathFinding.
http://www.stonetrip.com/developer/forum/viewtopic.php?f=13&t=25122&p=43631#p43631
Re: Enemy's Movement?
by CrazyPenguin » 27 Apr 2012, 11:29
DarkSoul, thank you very much!
If don't use navigation pathfinding.
I think, if this game is simple, maybe can create multiple dummys, add target to table, enemys AI can find it, but don't flexibly.
Please tell me if this is feasible,I will try to create.
thanks again.
If don't use navigation pathfinding.
I think, if this game is simple, maybe can create multiple dummys, add target to table, enemys AI can find it, but don't flexibly.
Please tell me if this is feasible,I will try to create.
thanks again.
ShiVa Basic Edition 1.9.1.0
Samsung Galaxy Nexus I9250 Android 4.0.2
Custom 3D : caijian9400@gmail.com
Samsung Galaxy Nexus I9250 Android 4.0.2
Custom 3D : caijian9400@gmail.com
-

CrazyPenguin - Fresh Boarder

- Posts: 13
Re: Enemy's Movement?
by DarkSoul » 27 Apr 2012, 22:32
You can use raycast to check if your dummy is visible or not, if it is visible, you can go to it. If you can move your character like a chess game, get the dummy position and translate your object on it.
Re: Enemy's Movement?
by CrazyPenguin » 28 Apr 2012, 07:22
Thank you for your response.
First,Just tested it,its work.
object.getTranslation ( hObject, kSpace )
object.getDirection ( hObject, kSpace )
I use scene.getFirstHitSensor.
if SensorID 0 is block, SensorID 2 is dummy
Enemy AI Example:
maybe there's a better way. Give us your best advice. Cheers
First,Just tested it,its work.
object.getTranslation ( hObject, kSpace )
object.getDirection ( hObject, kSpace )
I use scene.getFirstHitSensor.
if SensorID 0 is block, SensorID 2 is dummy
Enemy AI Example:
- Code: Select all
local hHitObject, nHitDist, nHitSensorID = scene.getFirstHitSensor( hScene, rx, ry, rz, dx, dy, dz, 100 )
if ( nHitSensorID == 0 )
then
log.message ( "Block Dist: ", nHitDist, " / ", hHitObject )
end
if ( nHitSensorID == 2 )
then
log.message ( "dummy is visible." )
this.sendEvent ( "onMove" )
end
maybe there's a better way. Give us your best advice. Cheers
ShiVa Basic Edition 1.9.1.0
Samsung Galaxy Nexus I9250 Android 4.0.2
Custom 3D : caijian9400@gmail.com
Samsung Galaxy Nexus I9250 Android 4.0.2
Custom 3D : caijian9400@gmail.com
-

CrazyPenguin - Fresh Boarder

- Posts: 13
5 posts
• Page 1 of 1
