Pathfinder angle re-initializatio when start movin

Bugs will be moved here once resolved.

Post » Thu Jun 27, 2013 8:00 pm

Link to .capx file :
https://www.dropbox.com/s/6b0lqvb8zb6cejh/bugPathFinder.capx

Steps to reproduce:
1. create a sprite with pathfinding
2. during execution, change sprite angle
3. calculate path/move along path

Observed result:
The sprite angle is reinitialized to its spawning angle before moving.

Expected result:
The sprite should start moving using its current angle.

Browsers affected:
Chrome: yes
Firefox: yes
Internet Explorer: yes

Operating system & service pack:
Windows 7 SP1

Construct 2 version:
r136



------
Some personal observations after research in the behavior code, the problem is that the a variable (the angle of the object, store into the behavior) is set on creation of object, and then used in the tick function when isMoving is set to true (starting moving), if the rotation is allowed of course.
But the behavior never calls runtime.add_bbox_changed_callback, never updating its inner angle (a), making it believe it never rotated, even if the sprite (or any over draw-able object in fact) called setAngle
Hope this helps.Guizmus2013-06-27 20:06:46
B
17
S
8
G
4
Posts: 461
Reputation: 6,107

Post » Thu Jun 27, 2013 8:59 pm

Well, I don't like problems I can't correct.
So here is the debug. In the runtime.js of the pathfinding behavior, just add the following code in the behinstProto.oncreateFunction, once this.a is set (line 73) :

          this.inst.add_bbox_changed_callback(function (_this){
              return function (inst) {
                    _this.a = inst.angle;
              };
          }(this));

I used what I learned from your code in particules plugin (the only one I found using the add_bbox_changed_callback function), but I didn't see any "remove_bbox_changed_callback", so I didn't know if and how to remove the eventlistener once the object is destroyed. Not finding the function in any other behavior made me think there was a more appropriate function, didn't find one though.Guizmus2013-06-27 21:08:54
B
17
S
8
G
4
Posts: 461
Reputation: 6,107

Post » Tue Jul 02, 2013 11:09 am

Should be fixed in the next build.
Scirra Founder
B
386
S
229
G
87
Posts: 24,207
Reputation: 191,692

Post » Tue Jul 02, 2013 11:58 am

@Ashley

Thanks a lot ! Looking forward to see how you corrected it, still learning all this :)
B
17
S
8
G
4
Posts: 461
Reputation: 6,107


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest