How to accelerate player in the direction they are looking?

Started by TheCatalystGaming on

Topic category: Advanced modding

Last seen on 19:36, 13. Nov 2022
Joined Nov 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to accelerate player in the direction they are looking?

I'm trying to create an item that allows the player to "dash" horizontally in the direction they are looking. I was thinking of using the procedure blocks that change an entities vx/vz but I don't know how to make that change to reflect the direction the player is looking.

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is what you are looking…
Sun, 05/31/2020 - 04:37

This is what you are looking for although you may want to play with the velocity, KEEP IN MIND THIS ALLOWS THE PLAYER TO FLY SO ADD A CHECK TO SEE IF THE PLAYER IS ON GROUND. I.e. if (playerIn.onGround = true)

        float yaw = playerIn.rotationYaw;
        float pitch = playerIn.rotationPitch;
        float velocity = 1.0F;
        double motionX = -MathHelper.sin(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(pitch / 180.0F * (float)Math.PI) * velocity;
        double motionZ = MathHelper.cos(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(pitch / 180.0F * (float)Math.PI) * velocity;
        double motionY = -MathHelper.sin((pitch) / 180.0F * (float)Math.PI) * velocity;
        playerIn.setVelocity(motionX, motionY, motionZ);

 

Last seen on 17:16, 16. Mar 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
or you can just use the…
Sun, 05/31/2020 - 15:49

or you can just use the procedure raytrace direction implemented in Mcreator

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sure the could! But the code…
Sun, 05/31/2020 - 16:11

Sure the could! But the code I provided is very good and works perfectly. And you can copy and paste (Although I really do not condone that, MCreator is about not coding so when I help out on the forums here I tend to just "give" code) it. Also, you can do a lot more complex things with this code. For instance, in my mod (not on MCreator) I add more y motion with a modifier (like a charging system).

Last seen on 17:16, 16. Mar 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
what the point of control c…
Sun, 05/31/2020 - 16:13

what the point of control c+v?

How can people learn from that?

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I also use this code with…
Sun, 05/31/2020 - 16:15

I also use this code with double jump and it works really well. But if MCreator has that sort of functionality go for it!

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The point none, but if you…
Sun, 05/31/2020 - 16:16

The point none, but if you like people learning code why do you condone using MCreator? I didn't read your last post when I posted my last post.

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Also like again, did you…
Sun, 05/31/2020 - 16:17

Also like again, did you read what I put in the parenthesis....

Last seen on 17:16, 16. Mar 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
When i first started html…
Sun, 05/31/2020 - 16:22

When i first started html and css, i used graphic editors, i suppose you learned java in one day?

Last seen on 17:16, 16. Mar 2024
Joined May 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you can never stop learning…
Sun, 05/31/2020 - 16:26

you can never stop learning and Mcreator is a good Tool for beginners/intermediate modders

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't disagree more…
Sun, 05/31/2020 - 16:31

I can't disagree more because I started on MCreator :D and will take the loss on this one. Even though when I said this, "you may want to play with the velocity..." I think I encouraged learning. But I have lots of respect for you and am sorry, I don't want to be obnoxious. I am leaving this thread

Last seen on 18:19, 13. Aug 2022
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Could you tell me the exact…
Wed, 07/08/2020 - 13:01

Could you tell me the exact name of this procedure? I want to make an item which let me dash forward when I right click with it, but I can't find the measure to do it.