MV How to do motion in RPG Maker MV?

Hey so I am trying to do a custom motion but it just doesn't work. Please help me out. Here's what I have so far in some Game_Actor function:

Spoiler: Code
var this_Sprite_Actor = new Sprite_Actor(this); this.requestMotion('swing'); this.requestMotionRefresh(); this_Sprite_Actor.updateMotion();
I'm still learning in JS so I can't really assist you thoroughly, but your script looks wrong. First there's no function to invoke, "this" keyword will not work.
If you wanted to just request swing animation, you can just use simple scriptcalls (I can't remember which but it start with $, probably look at the RPG_*.js)
A plugin named YEP action core also let you do that I believe.
I still don't know what to do!
var whatever = new Sprite_Actor(this) says "make a new sprite based on this actor". You're not adding it to any display object, so it won't show up.

To clarify, what are you trying to do?
  1. Animate an existing Sprite_Actor (e.g. in battle)?
  2. Create a new Sprite_Actor somewhere? If so: where, exactly?
  3. Something else?
I'm trying to animate an existing sprite_actor.
In that case, I think something like this should be sufficient:
JavaScript:
$gameParty.members()[0].requestMotion('swing');
I.e. "request the swing motion for party member 0 (i.e. the leader)". Sprites should automatically update based on their battlers. If you want them to do their attack motion, including their weapon, use performAttack instead, e.g.
JavaScript:
$gameParty.members()[0].performAttack();
...and if you want to reference an actor by their ID rather than their position in the party:
JavaScript:
$gameActors.actor(1).requestMotion('swing');

If you're using plugins then you might need a different approach. ^ Test this first, though! 👋
Okay $gameParty.members()[this.index()].performAttack(); has worked!!
Oh, if it's in a Game_Actor method then you could just use:
JavaScript:
this.performAttack();
Regardless, good to hear it's working! Happy RPG Making~ 😂

Original thread: https://forums.rpgmakerweb.com/threads/how-to-do-motion-in-rpg-maker-mv.138806/