ページ 11

マス目を無視した360度自由な移動で、プレイヤーやイベントに近づく/遠ざかる を実行したい

Posted: 2021年2月10日(水) 16:42
by じゅうし
・マス目を無視した360度自由な移動
で、
・イベントがプレイヤーに近づく

これは、うなぎおおとろさんのプラグイン
ドット移動システム
でできました。

加えて、360度自由な移動で
・イベントがプレイヤーから遠ざかる
・イベントに(他のイベントやプレイヤーが)近づく/遠ざかる
これを行いたいです。

イベントに近づく/遠ざかる は、今のところtomoakyさんの
TMMoveRouteExというプラグインで実行しています。

これらのプラグインを使う以外でも、実現できそうな方法があれば
教えて頂けると嬉しいです。
よろしくお願いします。

Re: マス目を無視した360度自由な移動で、プレイヤーやイベントに近づく/遠ざかる を実行したい

Posted: 2021年2月11日(木) 14:26
by じゅうし
ドット移動システムの、プレイヤーに近づく機能

Game_Character.prototype.dotMoveToPlayer = function() {
const fromPoint = { x: this._realX, y: this._realY };
const targetPoint = { x: $gamePlayer._realX, y: $gamePlayer._realY };
const deg = DotMoveUtils.calcDeg(fromPoint, targetPoint);
this.dotMoveByDeg(deg);
};

これをイベントに近づくように変えたものを追加することで、
イベントに近づく動きはできました。

Re: マス目を無視した360度自由な移動で、プレイヤーやイベントに近づく/遠ざかる を実行したい

Posted: 2021年2月11日(木) 16:35
by じゅうし
望む動きができました。
こんなにプラグインをいじったのは初めてで、なにかまずい個所がないか、
またはこうした方が良い、というのがあれば、教えていただけますでしょうか?
変えたのは
それぞれの1行目
Game_Character.prototype.の後と、
それぞれの3行目
{}の中だけです。


1.プレイヤーから遠ざかる

Game_Character.prototype.dotMoveAwayFromPlayer = function() {
const fromPoint = { x: this._realX, y: this._realY };
const targetPoint = { x: this._realX - $gamePlayer._realX + this._realX, y: this._realY - $gamePlayer._realY + this._realY };
const deg = DotMoveUtils.calcDeg(fromPoint, targetPoint);
this.dotMoveByDeg(deg);
};


2.イベントに近づく

Game_Character.prototype.dotMoveToEvent = function(eventId) {
const fromPoint = { x: this._realX, y: this._realY };
const targetPoint = { x: $gameMap.event(eventId)._realX, y: $gameMap.event(eventId)._realY };
const deg = DotMoveUtils.calcDeg(fromPoint, targetPoint);
this.dotMoveByDeg(deg);
};


3.イベントから遠ざかる

Game_Character.prototype.dotMoveAwayFromEvent = function(eventId) {
const fromPoint = { x: this._realX, y: this._realY };
const targetPoint = { x: this._realX - $gameMap.event(eventId)._realX + this._realX, y: this._realY - $gameMap.event(eventId)._realY + this._realY };
const deg = DotMoveUtils.calcDeg(fromPoint, targetPoint);
this.dotMoveByDeg(deg);
};