Spin player model without spinning view

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Kami
Global Moderator
Posts: 125
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Spin player model without spinning view

Postby Kami » Mon Jul 02, 2018 2:25 pm

Hey guys,
I'm currently exploring the idea to spin the players model but not his view.

I am able spin the player model and his view with this:

Syntax: Select all

from players.entity import Player
from events import Event
from mathlib import Vector
from listeners.tick import Repeat


@Event('player_say')
def player_say(ev):
player = Player.from_userid(int(ev['userid']))
angle = player.get_property_vector("m_angRotation")
vec = Vector(*angle)
repeat = Repeat(spin,(player,vec))
repeat.start(0.0,500,True)

def spin(player,angle):
angle[1] += 5.0
player.teleport(None,angle,None)


The result I'd like is the player model spinning for other players, but the player still beeing able to walk a straight line (spinning with angRotation will mess up your walking


Edit:

This is what I've come up with. I plan to add saving weapons. I remove the weapons because that will stop the walking animation from happening which was making the prop_dynamic go up and down

Syntax: Select all

from players.entity import Player
from events import Event
from mathlib import Vector
from listeners.tick import Repeat, RepeatStatus
from colors import Color
from entities.entity import Entity


@Event('player_say')
def player_say(ev):
player = Player.from_userid(int(ev['userid']))
player.color = Color(255,255,255,0)
for weapon in player.weapons():
weapon.color = Color(255,255,255,0)
ent = Entity.create('prop_dynamic')
ent.model = player.model
ent.origin = player.origin
ent.spawn()
ent.set_parent(player,'rfoot')
entity = Entity.create('player_weaponstrip')
entity.call_input("Strip", activator=player)
entity.remove()
angle = ent.get_property_vector("m_angRotation")
vec = Vector(*angle)
repeat = Repeat(spin,(ent,player,vec))
repeat.args += (repeat, )
repeat.start(0.1,50,True)

def spin(entity,player,angle,repeat):
angle[0] += 100.0
entity.teleport(None,angle,None)
entity.origin = player.origin
if repeat.status == RepeatStatus.STOPPED:
entity.remove()
player.color = Color(255,255,255,255)
player.give_named_item('weapon_knife')
for weapon in player.weapons():
weapon.color = Color(255,255,255,255)


Edit:

I just noticed that this will change the way the entity spins depending on where I look and where I stand, so that's not an option.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 0 guests