Syclamoth / GamesAI6

A repository for the assets folder of our GamesAI project
2 stars 0 forks source link

Wolfs don't do anything #4

Closed Andrew-Dunn closed 12 years ago

Andrew-Dunn commented 12 years ago

They just sit there. I'm 99% sure this was happening before I added pathfinding and turned them into prefabs. Please fix ASAP urgent.

zchaoz commented 12 years ago

Ofc they won't do anything because I've updated the their states. You should go to the FSM editor and link them again.

However, about the new states for wolf and sheep i.e. wolf_eating and sheep_beingeaten. They don't show on the FSM editor and I don't know why.

Also, with the new scene update last night. I got this error.

transform.position assign attempt for 'Wolf' is not valid. Input position is { NaN, 0.496794, NaN }. UnityEngine.Transform:set_position(Vector3) Legs:Update() (at Assets/Scripts/Interaction/Legs.cs:93)

Syclamoth commented 12 years ago

I'm fixing some/all of these now.

1: There's no reason why you can't set up the links on the FSM editor yourself, they're very straightforward.

2: They don't show up on the editor for a very good reason, which is that you haven't put them there (fixed now)

3: This error occurs if a wolf spawns inside a building. It basically screws up the steering behaviours and stops it from moving. Presumably when the wolf prefabs are being spawned in streets procedurally, it will no longer be an issue.

Andrew-Dunn commented 12 years ago

They are being spawned in streets automatically.

On 01/09/2012, at 7:27 PM, Kieren Wallace notifications@github.com wrote:

I'm fixing some/all of these now.

1: There's no reason why you can't set up the links on the FSM editor yourself, they're very straightforward.

2: They don't show up on the editor for a very good reason, which is that you haven't put them there (fixed now)

3: This error occurs if a wolf spawns inside a building. It basically screws up the steering behaviours and stops it from moving. Presumably when the wolf prefabs are being spawned in streets procedurally, it will no longer be an issue.

— Reply to this email directly or view it on GitHub.

zchaoz commented 12 years ago

About the FSM editor, everytime I open Sheep's FSM, it crashes Unity. It hasn't happened before.

There is also a warning on Grid.cs

The referenced script on this Behaviour is missing! UnityEngine.Object:Instantiate(Object, Vector3, Quaternion) SheepSpawn:SpawnSheep() (at Assets/Scripts/Game/SheepSpawn.cs:26) Grid:Start() (at Assets/Scripts/Environment/Grid.cs:112)

zchaoz commented 12 years ago

Ok, I CAN'T open Sheep's FSM editor to add Sheep_beingeaten state. It crashes my Unity.

Can anyone open it ?

Do Wolves need SetupSteering state like before?

Syclamoth commented 12 years ago

Wolves almost certainly need the SetupSteering state. Sorry, forgot about that one. I'm looking into the sheep thing now.

EDIT: The sheep state seems to be working fine for me. Try committing and merging, it's possible that I've broken something or that something isn't matching up between versions properly.

Syclamoth commented 12 years ago

Ok, the wolves move properly now. Still not sure what's going on with the sheep, I'm not seeing that problem on my end.

Syclamoth commented 12 years ago

Ok I worked out what the problem was with the sheep. Basically, there were some components on the sheep that did not have the proper scripts 'attached'- upon further investigation I found that the name of the file was different from the name of the class- while this will not cause a compiler error, Unity will not allow you to add a component if the filename does not exactly match the classname, and so the state was not being properly added to the machine.

zchaoz commented 12 years ago

Ty Keiren. Sheep is doing fine.

However, the Wolves don't flee away from the player nor catch the sheep on my Unity. Sometimes, the Sheeps don't reg the Shepherd i.e. don't follow him.

Is it a bug or just me only ? If it's just me, don't worry about it. My Unity was broken ages ago. The camera and map on my screen are broken too. I can't see any probe, light or colour on objects

In the meantime, I stay away from modifying scenes file.

Andrew-Dunn commented 12 years ago

I fixed the warning (which completely bugged up level generation)

zchaoz commented 12 years ago

Sometimes, this bug appears out of nowhere

NullReferenceException: Object reference not set to an instance of an object AStarNode..ctor (.GridSquare square, .GridSquare target) (at Assets/Scripts/Environment/Grid.cs:1053) Grid.findPath (Vector3 pathFrom, Vector3 pathTo) (at Assets/Scripts/Environment/Grid.cs:680)

Do I need to change the ArriveBehaviour in Wolf and Sheep to Pathfinding.cs ? Grid.Update () (at Assets/Scripts/Environment/Grid.cs:291)

Andrew-Dunn commented 12 years ago

Nope, Pathfinding.cs is superceded and was really more just a pseudocode thing. Use Grid.findPath() if you need to find a path, or even better use the new Pathfind.cs pathfinding steering behaviour

zchaoz commented 12 years ago

Ok, changing arrivebehaviour to pathfind.cs now.

Also, Keiren, can you link Sheep_roaming state to Sheep_beingeatenn state on the FSM editor ? It seems I can't link and save it for some unknown reason.

Whenever I link them and click save (scene and project), the next time I open the scene again, the link isn't there anymore.

zchaoz commented 12 years ago

I took a look at your example in pathfind.cs

So if I want to add this behaviour to Sheep_roaming state, I do something like:

Pathfind b = new Pathfind(); b.Init(this.legs, myBrain.levelGrid);

b.setTarget(GameObject.FindGameObjectWithTag("Player"));

Am I right ?

There is also a bug when I tried to run this too:

StackOverflowException UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) (at C:/BuildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:101) TargetableSteeringBehaviour.getTarget () (at Assets/Scripts/Interaction/Steering Behaviours/TargetableSteeringBehaviour.cs:20) Pathfind.onTarget () (at Assets/Scripts/Interaction/Steering Behaviours/Pathfind.cs:22)

Andrew-Dunn commented 12 years ago

Can you push to a new branch?

zchaoz commented 12 years ago

Done, I push it to another branch: Sheep_roaming state with pathfind.cs

Andrew-Dunn commented 12 years ago

arriveBehaviour.Init(myLeg); is wrong It needs a second argument detailing the grid (a component of terrainbase).

zchaoz commented 12 years ago

Yep, where can I get it ? Is it from myBrain.levelGrid?

Andrew-Dunn commented 12 years ago

Fixed the stackoverflow error.

zchaoz commented 12 years ago

Another error popup:

NullReferenceException: Object reference not set to an instance of an object AStarNode..ctor (.GridSquare square, .GridSquare target) (at Assets/Scripts/Environment/Grid.cs:1053) Grid.findPath (Vector3 pathFrom, Vector3 pathTo) (at Assets/Scripts/Environment/Grid.cs:680) Pathfind.onTarget () (at Assets/Scripts/Interaction/Steering Behaviours/Pathfind.cs:25) TargetableSteeringBehaviour.setTarget (UnityEngine.GameObject target) (at Assets/Scripts/Interaction/Steering Behaviours/TargetableSteeringBehaviour.cs:17)

And yep, I'm using arriveBehaviour.Init(myLeg, myBrain.levelGrid);

Andrew-Dunn commented 12 years ago

should be all fixed

zchaoz commented 12 years ago

Done, they are all fixed. Ty Andrew.

I checked the Wolves again. They don't sense Player and Sheeps. Thought?

Sheep can sense the Wolf, however they are not responsive in following the Player. With the pathfind steering behavior, they roam around more than before when using the ArriveBehaviour.