Hi,
i would like to create a mod that, when the player walks near an one block high obstacle, the player automatically jumps. (IIRC this is the common behaviour in MC PE)
The problem is I don't know how to start at all. Is there some code that I could "borrow" from a similar mod?
I guess the mobs mods might have something useful as the animals can walk up hills, but I haven't found the right lines yet.
Mod idea - Autojump
-
Rochambeau
- Member
- Posts: 119
- Joined: Tue Sep 23, 2014 11:37
Re: Mod idea - Autojump
I wouldn't recommend doing this from lua, but...
You can:
- invoke player:get_yaw()
- read player:get_player_controls().up
- and if there's a node at player:getpos() + vector, received from yaw and the second one is TRUE, then jump.
The only problem is that you can't invoke a jump.
So, I'd not recommend you to continue this way, but...
You can:
- create an entity at player:getpos()
- attach a player to it
- make it jump (see mobs by PilzAdam)
- detach the player and remove the entity.
But. as I've said... look at the android controls. Maybe an autojump option for PC edition won't be so horrible to prevent it from merging.
Regards!
You can:
- invoke player:get_yaw()
- read player:get_player_controls().up
- and if there's a node at player:getpos() + vector, received from yaw and the second one is TRUE, then jump.
The only problem is that you can't invoke a jump.
So, I'd not recommend you to continue this way, but...
You can:
- create an entity at player:getpos()
- attach a player to it
- make it jump (see mobs by PilzAdam)
- detach the player and remove the entity.
But. as I've said... look at the android controls. Maybe an autojump option for PC edition won't be so horrible to prevent it from merging.
Regards!
Re: Mod idea - Autojump
I like the idea for android build : it's hard to point, push up and jump without dropping your phone.
For simple mobs, as I understand, when the mob is moving but its velocity is inferior than a certain value (0.5 in normal walk and 1.5 in following walk), you just change the y velocity (which is often null) by 5 or 6. The mob will jump.
For simple mobs, as I understand, when the mob is moving but its velocity is inferior than a certain value (0.5 in normal walk and 1.5 in following walk), you just change the y velocity (which is often null) by 5 or 6. The mob will jump.
My build : viewtopic.php?f=42&t=10554
- Calinou
- Member
- Posts: 3168
- Joined: Mon Aug 01, 2011 14:26
- GitHub: Calinou
- IRC: Calinou
- In-game: Calinou
- Location: Troyes, France
- Contact:
Re: Mod idea - Autojump
Change the step height in the source code. This way, you have something fully client-side, usable on any server, without lag.
localplayer.cpp line 194:
Change BS*0.6 to BS*1.1 then recompile.
I believe this step height could automatically be used on Android builds, it seems fair considering controls are harder to use there.
camera.cpp line 275:
Change -23 to -7 for more smoothing. -10 is a good value with the default step height, but here we are stepping up larger heights.
localplayer.cpp line 194:
Code: Select all
float player_stepheight = touching_ground ? (BS*0.6) : (BS*0.2)I believe this step height could automatically be used on Android builds, it seems fair considering controls are harder to use there.
camera.cpp line 275:
Code: Select all
f32 t = exp(-23*frametime);Re: Mod idea - Autojump
That's really useful. I'm building my client with this from now on. Thanks, Calinou!Calinou wrote:Change the step height in the source code. This way, you have something fully client-side, usable on any server, without lag.
-
Sokomine
- Member
- Posts: 4317
- Joined: Sun Sep 09, 2012 17:31
- GitHub: Sokomine
- IRC: Sokomine
- In-game: Sokomine
Re: Mod idea - Autojump
Sounds like a very good idea, especially regarding the android client. It would be great if it could be made configurable.Calinou wrote: Change the step height in the source code.
The drawback is that an increased step height will make braking at the end of roads in fast move more difficult.
A list of my mods can be found here.
Who is online
Users browsing this forum: Google [Bot] and 2 guests