cutscene entity never moves, rotates - only one animation?

Post Reply
User avatar
22i
Member
Posts: 22
Joined: Sat May 20, 2017 18:52
GitHub: 22i

cutscene entity never moves, rotates - only one animation?

by 22i » Post

lately i have been thinking about creating a cutscene like thing. It could work by being an entity that never moves or rotates and only has one animation that it plays from start to finish. I could create the whole cutscene animation in blender then export it for minetest. You could trigger the entity animation in multiple ways:

- by entering command /cutscene 1 which would spawn cutscene entity near you and start playing its animation
- comming close to the entity like in its 10 blocks radius
- pressing a button
- stepping on a pressure plate

How can this be done?

User avatar
AiTechEye
Member
Posts: 1000
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: Sweden

Re: cutscene entity never moves, rotates - only one animatio

by AiTechEye » Post

download/file.php?mode=view&id=17121

the default character / sam is used


cutscene:button starts animation for those that are nearer than 50
cutscene:pressure_plate start...
cutscene:button_stop stop...
/cutscene 1 to spawn one and start anim...
animation starts when you are 10 or nearer them

have fun!

Code: Select all

minetest.register_craft({
	output = "cutscene:button",
	recipe = {
		{"default:wood"},
		{"default:cobble"},
		{""},
	}
})

minetest.register_craft({
	output = "cutscene:button_stop",
	recipe = {
		{"default:wood"},
		{"default:wood"},
		{"default:cobble"},
	}
})

minetest.register_craft({
	output = "cutscene:pressure_plate",
	recipe = {
		{"stairs:slab_wood"},
		{"default:cobble"},
		{""}
	}
})

minetest.register_chatcommand("cutscene", {
	params = "",
	description = "Spawn cutscene",
	func = function(name, param)
		if param=="1" then
			local pos=minetest.get_player_by_name(name):get_pos()
			local ob=minetest.add_entity({x=pos.x,y=pos.y+1.5,z=pos.z+3}, "cutscene:play1")
--				               start  end       speed loop
			ob:set_animation({x=1, y=250},30,0)
			
		end
	end
})

minetest.register_node("cutscene:button", {
	description = "Button",
	groups={cracky=3},
	tiles={"gui_hotbar_selected.png"},
	on_rightclick = function(pos, node, player, itemstack, pointed_thing)
		for _, ob in ipairs(minetest.get_objects_inside_radius(pos, 50)) do
			if ob:get_luaentity() and ob:get_luaentity().name=="cutscene:play1" then
				ob:set_animation({x=1, y=250},30,0)
			end
		end
	end
})

minetest.register_node("cutscene:button_stop", {
	description = "Button",
	groups={cracky=3},
	tiles={"gui_hotbar_selected.png"},
	on_rightclick = function(pos, node, player, itemstack, pointed_thing)
		for _, ob in ipairs(minetest.get_objects_inside_radius(pos, 50)) do
			if ob:get_luaentity() and ob:get_luaentity().name=="cutscene:play1" then
				ob:set_animation({x=0, y=0},0,0)
			end
		end
	end
})


minetest.register_node("cutscene:pressure_plate", {
	description = "Pressure plate",
	groups={cracky=3},
	tiles={"gui_hotbar_selected.png"},
	paramtype="light",
	drawtype="nodebox",
	node_box = {
		type = "fixed",
		fixed = {
			{-0.5, -0.5, -0.5, 0.5, -0.4, 0.5},
		}
	},
	on_construct=function(pos)
		minetest.get_node_timer(pos):start(1)
	end,
	on_timer = function (pos, elapsed)

		local pressured=false
		for _, ob in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
			pressured=true
			break
		end

		if pressured==true then
			for _, ob in ipairs(minetest.get_objects_inside_radius(pos, 50)) do
				if ob:get_luaentity() and ob:get_luaentity().name=="cutscene:play1" then
					ob:set_animation({x=1, y=250},30,0)
				end
			end
		end
		return true
	end,
})



minetest.register_entity("cutscene:play1",{
	hp_max = 20,
	physical = true,
	collisionbox = {-0.35,-1,-0,0.35,0.8,0},
	visual =  "mesh",
	mesh = "character.b3d",
	textures = {"character.png"},
	is_visible = true,
	makes_footstep_sound = false,
	on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
		self.object:remove()
	end,
	on_step=function(self, dtime)

		if self.timer>0 then
			self.timer=self.timer+dtime
			if self.timer>5 then
				self.timer=0
			end
			return
		end

		local pos=self.object:get_pos()
		for _, ob in ipairs(minetest.get_objects_inside_radius(pos, 10)) do
			if ob:is_player() then
				self.object:set_animation({x=1, y=250},30,0)
				self.timer=1
			end
		end
	end,
	timer=0,
})
Attachments
cutscene.zip
(1.06 KiB) Downloaded 74 times

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests