How to do a "camera" knockback when using a ranged item

Started by Righty on Mon, 08/03/2020 - 17:58

Topic category: Help with modding (Java Edition)

Last seen on 18:43, 3. Aug 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How to do a "camera" knockback when using a ranged item
Mon, 08/03/2020 - 17:58

I wanted to do a P90 but someone gave me a good idea and told me to make a "knockback" for the user of the weapon.
So when you shoot the weapon your camera would go up a bit.

So i made a new procedure etc...

But then the console go this error for me.
C:\JUST MY FOLDERS\ProcedureP90fires.java:19: error: incompatible types: possible lossy conversion from double to float       entity.rotationYaw = Math.random();
                                                                                                                                                                                                                                                              ^
C:\JUST MY FOLDERS\ProcedureP90fires.java:20: error: incompatible types: possible lossy conversion from double to float       entity.rotationPitch = Math.random();
                                                                                                                                                                                                                                                               ^

Last seen on 18:43, 3. Aug 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Well the image didn't work…
Mon, 08/03/2020 - 18:01

Well the image didn't work so here it is:

Event trigger - triggered by external call
or when (global trigger): No additionnal trigger\/

Set entity rotation yaw: Random[0,1) pitch: Random[0,1)

Last seen on 23:33, 26. Sep 2020
Joined Jul 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
It sounds like you can't use…
Tue, 08/04/2020 - 03:08

It sounds like you can't use the <random [0,1]> for the yaw and pitch, because the <random [0,1]> uses a "double", a number twice as exact as the "float" number the yaw and pitch use, causing an error.

Last seen on 19:43, 29. Sep 2020
Joined May 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
You should not set the…
Mon, 08/10/2020 - 22:05

You should not set the player's rotation to a random number, but instead add to the player's existing rotation. This way, it will make the outcome much more controlled and the camera will move to a relatively close position instead of somewhere completely random.

As for the float-double mismatch. I think the round block could solve your issue there.

Last seen on 23:33, 26. Sep 2020
Joined Jul 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Also, if you can get the…
Tue, 08/11/2020 - 06:51

Also, if you can get the random block to work, you may want to multiply your outcome by 2+ so the angle difference is noticable.