半円の回転

正面に斬撃を出す、っていうことをしたいんですが この半円をどうやって向いている方向に出すか(回転させる?)かが分かりません
8 Replies
gladiolus8789
gladiolus8789OP2y ago
右の写真みたいにしたいです 今円の描画は
function editCircle(r: number, p: player, count: integer):
set {_theta} to yaw of {_p}
loop {_count} times:
set {_x} to x-loc of {_p} + ({_r} * cos({_theta}) * -1)
set {_y} to y-loc of {_p} + ({_r} * sin({_theta}) * -1) +1
set {_z} to z-loc of {_p} + ({_r} * cos({_theta}) * -1)
remove 1 from {_theta}
execute console command "particle flame %{_x}% %{_y}% %{_z}% 0 0 0.01 0 10 force"
function editCircle(r: number, p: player, count: integer):
set {_theta} to yaw of {_p}
loop {_count} times:
set {_x} to x-loc of {_p} + ({_r} * cos({_theta}) * -1)
set {_y} to y-loc of {_p} + ({_r} * sin({_theta}) * -1) +1
set {_z} to z-loc of {_p} + ({_r} * cos({_theta}) * -1)
remove 1 from {_theta}
execute console command "particle flame %{_x}% %{_y}% %{_z}% 0 0 0.01 0 10 force"
これでやってます
tanoKun
tanoKun2y ago
eggeに任せれば解決「
何か
何か2y ago
半円の斬撃は単純にベクトルの回転で考えます
何か
何か2y ago
何か
何か2y ago
視線方向の緑のベクトルとそれに垂直な青のベクトル この二つに垂直な水色のベクトルを考えて 水色のベクトルを青ベクトル周りに180度回転させます そうすると赤矢印の軌道を描きます
何か
何か2y ago
何か
何か2y ago
視点方向に垂直なベクトルは内積がゼロになるベクトルなので
function right(v: vector) :: vector:
set {_x} to -1 * z of {_v}
set {_y} to 0
set {_z} to x of {_v}
set {_v} to vector({_x}, {_y}, {_z})
set vector length of {_v} to 1
return {_v}
function right(v: vector) :: vector:
set {_x} to -1 * z of {_v}
set {_y} to 0
set {_z} to x of {_v}
set {_v} to vector({_x}, {_y}, {_z})
set vector length of {_v} to 1
return {_v}
これで単純に考えられます 二つのベクトルに垂直なベクトルは外積から得られます
every 1 tick:
loop all players:
set {_look} to vector from yaw yaw of loop-player and pitch pitch of loop-player
set {_right} to right({_look})
set {_v} to {_look} cross {_right}
every 1 tick:
loop all players:
set {_look} to vector from yaw yaw of loop-player and pitch pitch of loop-player
set {_right} to right({_look})
set {_v} to {_look} cross {_right}
set {_pos} to eye of loop-player
loop 10 times:
flame({_pos} ~ {_v} ~ {_look})
rotate {_v} around {_right} by 18
set {_pos} to eye of loop-player
loop 10 times:
flame({_pos} ~ {_v} ~ {_look})
rotate {_v} around {_right} by 18
あとは単純にベクトルを回転させて位置を調整すれば斬撃になります
gladiolus8789
gladiolus8789OP2y ago
できました!ありがとうございます! https://gyazo.com/cc64998027676226df5b711109560cc8
Gyazo
Gyazo
Want results from more Discord servers?
Add your server