메뉴 건너뛰기

cuiwenchu

취미생활
2018.02.05 04:24

gamesalad magnitude

chu
조회 수 3679 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

2014年8月22日 星期五

gamesalad magnitude(向量絕對值)的用法


先說在前面,
本人對數學其實並不十分有興趣,
也並非技術背景出身的人員,
以下的內容,
對遊戲製作沒有興趣的人,看起來應該也會覺得很沉悶吧@@


這個magnitude(向量絕對值)一詞,
因為之前沒看過,是一個不懂的新字,
所以光看就覺得很威的樣子,
直到看到國外gs開發者的用法,
才知道是怎麼一回事,
封面圖是用google找到的一張能簡單說明的示意圖,
但是如果我沒看過以及用gs實做過,
我也不會有興趣去瞭解這不知道能幹嘛用只是看起來好像很厲害的專有名詞^^"

用上面的圖說解示,
就是由某一點(頭)到某一點(尾)間的距離取絕對值,
主要是在向量的世界裡取得距離用的。
(3D的世界裡我想應該也是一樣的原理)

那在遊戲製作中,
在gamesalad這套工具裡能用來做什麼呢?

原來可以拿來改變碰撞範圍的大小,
在gs中,
任何物件的hitbox(碰撞範圍)預設都是本身拖進場景中的方塊的大小,
gs號稱不需要"寫"程式?
但是如果你只用內建不更動程式的方式的預設工具去製作,
是沒辦法做到改變hitbox(碰撞範圍)的,
視覺化編輯器中的actor看到的方塊就一定得是碰撞範圍。

如果要做一些進階的變化,
我這邊立刻聯想到的例子是彈幕射擊遊戲,
比如cave社的怒首領蜂系列,
飛機的可視圖像內含極小的自身碰撞判定,
所以可以做出即使被子彈擊中機身圖像,
除非被打中中心點那極小的hitbox(碰撞範圍),否則不會被擊落的效果,
就一定要使用magnitude(向量絕對值)去自訂hitbox(碰撞範圍)。


用實際在gs中製作的情形來說明,
跟怒首領鋒系列相反,
為了方便說明,使用的是超過本身圖像之外的碰撞判定來當圖示,
上圖中觸碰左邊方塊的中心A點時,
右邊的文字方塊顯示用magnitude得出的數值是大約1.3。
(如果能剛好碰到正中心的話會是0,
但理論上來說人的手指或滑鼠是不可能剛好碰到正中心點的)


上圖中觸碰左邊方塊的B點的虛線任何一處時,
右邊的文字方塊顯示用magnitude得出的數值是大約60。
也就是說,
A點(方塊的中心點)到B點黃色虛線的任一處的magnitude(向量絕對值)是60。

在gs中要取得上圖例子中文字方塊顯示的數值,
只需要用A點的座標減掉B點的座標就可以了。


magnitude裡要輸入兩個值,分別是X跟Y,
像這樣

===========
magnitude(X,Y)
===========

所以可以先設一個real性質的全域變數,比如叫做magnitude,
再把magnitude計算後的結果紀錄起來,

magnitude = magnitude( self.Position.X - game.Mouse.Position.X , self.Position.Y - game.Mouse.Position.Y )

這樣就可以再用任何數字去決定hitbox(碰撞範圍),
如果方塊的面積是60x60,
那設定magnitude < 70才觸發碰撞條件的話,
就會在方塊周圍產生像圖示的黃色虛線一樣,
多出看不見的10(70-60=10)的距離範圍也會被當作觸發碰撞判定,
如果想要設定小於方塊本身的hitbox(碰撞範圍),
像怒首領鋒那種極小hitbox(碰撞範圍)的話,
就只要設小於本身方塊的數值就可以了,
比如magnitude < 20才觸發碰撞條件,
就算碰觸到原本有顯示的方塊區也不會觸發了。

這個magnitude(向量絕對值)我想很多開發工具應該都有類似的用法,
比如說像以前flash的hitArea就有點接近,
而在unity要設定碰撞範圍應該是更容易才是,
只是換一個名詞變成magnitude後,
因為是平常比較少用的生硬英文,
就看起來變成很厲害,
其實運作原理並沒有字面上看到的那麼難理解,
難怪網路上流傳著一個笑話...

要學好程式最先要學哪一種語言比較好?




List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
14040 Channel Seven Is Striking Onerous With The Return Of Five Major Packages Premiering In Coming Weeks Whereas Community Ten Will Roll Out A Staggering Eight New And Returning Exhibits. The Collection Will Feature A Brand New Ship, New Characters And Ne new Lemuel45O905322 2018.06.20 0
14039 He Was Even Given The VIP Therapy In The Course Of The Shoot By Having His Own Hairdresser Who Hooked Up 40 Clips To His Locks For Every Day Of Filming. Writer: Markdvd Doctor Who Is A British Science Fiction Television Programme Produced By The BBC. new Lemuel45O905322 2018.06.20 0
14038 Test Back To Seek Out Out! Nashville Was Looking To Get Back To The Cup Closing After Falling To Pittsburgh Last Spring, Whereas Colorado Was Coming Off A Miserable 48-point Season. There Are Tons Of People Who Are Attracted To It And Can Have The Ab new ArethaI23962385 2018.06.20 0
14037 The First Season Right Here Is Definitely The American Version, And Never The UK Model With The Extra Superior Opening Music, So That Is Another Factor To Remember - However To Me It Is Only A Minor Subject. You May Think That You're Relaxed, But Whe new CamilleOcampo136 2018.06.20 0
14036 Apple IPad, Computer Trade Giants Have Lastly Started To Broaden The "counterattack." Tablet Laptop's "Hundred Flowers", Might Quickly Set Off A Worth Struggle. One Can See How Burton Might Have Made This Error As A 16mm Movie Strip Could Look The Sa new Lemuel45O905322 2018.06.20 0
14035 All You Need To Do Is Allow World Learn About Your Plan Via A Nicely-designed, Low Cost Advertising And Marketing Marketing Campaign, And You Will Basically Handle To Attain An Necessary Revenue From Your Organization With Minimal Effort. Some Of The new ArethaI23962385 2018.06.20 0
14034 I Scoffed At The Idea Of Her Being Ready To Achieve One Thing So Academically Difficult, However I Had Excessive Hopes For Myself. When You Buy New Seat Covers Or Need To Ensconce A Cushion Supervise In Your 1 Din Car DVD Player, The Very Last Thing new CamilleOcampo136 2018.06.20 0
14033 With Every New Dallas Release, I Expect The Present To Finally Begin Sucking, And This Was The Primary Set The Place It Appeared Like Which May Actually Be The Case. He May Flip To You And Ask To Your Opinion Of A Film. As By Yourself’ll View Afterwa new Lemuel45O905322 2018.06.20 0
14032 Not Utilizing The Web - A Sort Of Web Luddism - May But Grow To Be A Badge Of Honor. Using A Brush With Rough, Wiry Bristles Can Contribute To Weakened Strands And Unhealthy Hair. The Dry And Scorching Season Can Also Hinder The Health Of Our Lawn Gr new ArethaI23962385 2018.06.20 0
14031 Bed Linens And Tub Linen Are Additionally Replaced Regularly, However As Soon As Extra, Might Much More Be Wanted, A Lot Lodging Workers Are Pretty Completely Satisfied To See To It. Simply Put Them To Work And Soon, You Will See Your Recreation Impr new CamilleOcampo136 2018.06.20 0
14030 " The Policeman Asked. "It Looked Like A Military Plane." However, At The Same Time, It Didn’t. But, It Doesn’t Mean You Are Going To Get The Lowest Possible Charges. You Can Explore Patchwork Quilt Which Are Well-known At Berry Markets. However What new JodiMorehead0720 2018.06.20 1
14029 Each Of The Books Has Acquired Reward For Being In A Position To Maintain Readers Intrigued. All That Was Required Was A Timepiece That Could Keep Time. Cracksin Richard’s Newest Relationship End Up Being Additional Noticeable When He Is Actually Obl new DaleFosbrook7069 2018.06.20 8
14028 The Very Last Thing George Said To Me Was The Yr "1532" As A Time That He Was Most Happy. If His Past Is Any Indicator The Staff Will Respond This Season By Over Achieving Then He'll Lose Their Respect By Subsequent 12 Months. You Have To Absorb Mind new MeriSnl41950241508 2018.06.20 0
14027 In Order To Give Others Reliable And Goal Bluray Rippers Evaluations, To Really Save Your Time On Looking For An Easy-to-use And Effective Blu-ray Ripper, They Downloaded The Favored Bluray Rippers And Test Them Rigorously. After Testing Plenty Of Bl new HamishBage0716934 2018.06.20 0
14026 Digital Outlets Have Been Particularly Keen To Try Out Their Offerings Here, With Fb And The Huffington Submit Looking North To Validate New Ideas Before Making Use Of Them To The Bigger U.S. Publisher: SAPerillo It's No Secret That Ladies Are Obsess new DaleFosbrook7069 2018.06.20 0
14025 Writer: Markdvd The Godfather Obtained Academy Awards For Finest Image, Greatest Actor, And Greatest Adapted Screenplay, And Has Been Selected For Preservation Within The United States Nationwide Film Registry. The Actor, Who Found Out Late Final Wee new DaleFosbrook7069 2018.06.20 0
14024 So As To Give Others Reliable And Goal Bluray Rippers Critiques, To Actually Save Your Time On Looking For An Easy-to-use And Effective Blu-ray Ripper, They Downloaded The Popular Bluray Rippers And Test Them Carefully. After Testing A Variety Of Blu LauriPhilpott987 2018.06.19 16
14023 And For These Of You Who Are Wondering, Yes, It Does Lock The Bolt Open On An Empty Journal, A Minimum Of On The One That Came With My Review Gun. Actually The Honour Of Using A Drone At Least Goes Back To Fellow Nessie Hunter, Gordon Holmes, Who Was LauriPhilpott987 2018.06.19 7
14022 Signal-up Free Of Charge Trial! If You Are New To This Wiki, Please Observe Our Policies And Tips, And In The Event You Get Caught Feel Free To Check In At The Help Desk. Seek For Movie Harlots Season 1. Get A New Collection Harlots Season 1. Watch O LauriPhilpott987 2018.06.19 4
14021 The Thirteen-episode Drama Was First Put In Development In October 2013 And Picked As Much As Collection In September 2014 And Not Using A Cast Connected. Martin's Epic Fantasy Sequence A Track Of Ice And Hearth, The Popular HBO Present Typically Fee ReinaMcEvoy2208 2018.06.19 8
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 702 Next
/ 702