Contacts
صفحه اصلی پورتال | صفحه اصلی تالار | ثبت نام | اعضاء | گروه ها | جستجو | پرسش و پاسخ | فروشگاه الکترونیکی | خرید پستی بازی های کامپیوتری





صفحه اول انجمنها -> ساخت بازی با نرم افزار 3D Game Studio -> رد نشدن جسم از اجسام
 

ارسال يك موضوع جديد   پاسخ به يك موضوع ديدن موضوع قبلي :: ديدن موضوع بعدي
برو به صفحه 1, 2  بعدي

رد نشدن جسم از اجسام
نويسنده
پيغام
عماد11
بازی ساز
بازی ساز


تاريخ عضويت: جمعه 7 اسفند 1383
تعداد ارسالها: 229
محل سكونت: تهران


1 شنبه 7 اسفند 1384 - 07:03
پاسخ بصورت نقل قول
با سلام
مي خواستم جسم من از ديوارها و مدل ها رد نشود لطفاٌ توضيح دهيد چگونه؟ Surprised

_________________
ارسال  بازگشت به بالا
ديدن مشخصات كاربر ارسال پيغام خصوصي نام كاربري در پيغامگير Yahoo
 

نويسنده
پيغام
مهمان







1 شنبه 7 اسفند 1384 - 19:03
پاسخ بصورت نقل قول
احتمالا شما اصلا از اسکریپت استفاده نمیکنید و فقط مراحل را طراحی کرده اید . در هر حال توضیح دهید که اسکریپت نوشته اید یا اینکه از اسکریپتهای آماده استفاده میکنید یا اصولا اسکریپتی استفاده نمیکنید ؟

در حالت استاندارد زمانی که شما از اسکریپت استفاده میکنید و برنامه با اسکریپت فعال میشود ، دیوار ها غیر قابل نفوذ هستند ..

موفق باشی: ستاره Surprised
ارسال  بازگشت به بالا
 

نويسنده
پيغام
عماد11
بازی ساز
بازی ساز


تاريخ عضويت: جمعه 7 اسفند 1383
تعداد ارسالها: 229
محل سكونت: تهران


2 شنبه 8 اسفند 1384 - 18:35
پاسخ بصورت نقل قول
من خودم يك بازي ماشين سواري دارم مي سازم
و همه ي اسكريپ آن را خودم نوشتم لطفا بگوييد چي كار كنم چون ماشين من از ديوارها رد مي شود . . Crying or Very sad

_________________
ارسال  بازگشت به بالا
ديدن مشخصات كاربر ارسال پيغام خصوصي نام كاربري در پيغامگير Yahoo
 

نويسنده
پيغام
مهمان







5 شنبه 11 اسفند 1384 - 07:54
پاسخ بصورت نقل قول
بسیار خب عماد جان !
من اسکریپتی در زیر مینویسم که میتونه مشکلت رو حل کنه . برای مشاهده صحیح کد ها ، تمام آنرا کپی کن و سپس در محیط Script Editor توسط گزینه Paste وارد کن . دستورات زیر ، کد کامل یک بازیگر است که از زمین و همچنین دیوار ها عبور نمیکند . کد ها دارای توضیحات کافی و کاملی هستند و من خودم بارها آنرا تست کرده ام :

var camera_distance = 200; // distance from the player to the camera in 3rd person mode
var camera_height = 40; // distance from the origin of the player to the camera (on the z axis)
var distance_traced; // distance that is return by a trace instruction
var temporary_distance;
var camera_mode; // starts in 3rd person mode, changes to 1 for first person

/////////////////////////////////////////////////////////////////////////////////

function avoid_obstacles();
function first_person_camera();
function third_person_camera();

/////////////////////////////////////////////////////////////////////////////////

sound step_wav = <step.wav>;

/////////////////////////////////////////////////////////////////////////////////

action player1
{
player = my; // I'm the player
my.x = -2700; // set the proper position and orientation for the player
my.y = -2500; // this is useful if you have a huge level and the player is too small to be noticeable on the map in Wed
my.z = -2000;
my.pan = 160;
my.transparent = on; // the player is transparent
my.alpha = 100; // but opaque if the camera doesn't run into obstacles
my.skill40 = camera_distance; // we store the distance to the camera
my.skill41 = camera_height; // and its height
camera_mode = 3; // the game starts with the camera in 3rd person mode
while (1)
{
player.pan -= 10 * mouse_force.x * time - 1.5 * (key_a - key_d); // player's pan is controlled by the mouse and the "A" and "D" keys
camera.x = player.x - camera_distance * cos(player.pan); // keep the camera behind the player
camera.y = player.y - camera_distance * sin(player.pan); // at the distance given by camera_distance
camera.z = player.z + camera_height + 0.8 * sin(my.skill46 * 3.6); // and above the player
camera.pan = player.pan; // the camera has the same pan angle with the player
camera.tilt += 7 * mouse_force.y * time; // and can tilt freely
camera_distance = min (max (camera_distance, 5), 500); // camera_distance can have values between 5 and 500
if (key_w + key_s > 0) // if the player is walking
{
ent_cycle("walk", my.skill46); // play its "walk" frames animation
my.skill46 += 10 * (1 + key_shift * 0.5) * time; // the animation speed increases when the player presses the "shift" key
my.skill46 %= 100; // loop the animation
}
else // if the player is standing
{
my.skill47 = 0; // reset the skill that stores the distance needed for the step sound (not really needed)
ent_cycle("stand", my.skill48); // play the "stand" frames animation
my.skill48 += 2 * time; // "stand" animation speed
my.skill48 %= 100; // loop animation
}
if (camera_mode == 3) // if we are in 3rd person mode
{
avoid_obstacles(); // run the function that avoids camera collisions with the relief
}
vec_set (temp, my.x); // trace 10,000 quants below the player
temp.z -= 10000;
trace_mode = ignore_me + ignore_passable + use_box;
temp.z = -trace (my.x, temp); // and adjust its height accordingly, placing its feet on the ground
// allow the player to move using the "W" and "S" keys; the speed increases to 200% if the player presses the "shift" key
temp.x = 10 * (key_w - key_s) * (1 + 1 * key_shift) * time;
temp.y = 0;
my.skill47 += ent_move (temp, nullvector);
if (my.skill47 > 50) // play with 50 (here we've got a step sound every 50 quants)
{
snd_play(step_wav, 30, 0);
my.skill47 = 0;
}
wait (1);
}
}

function avoid_obstacles()
{
trace_mode = ignore_me + ignore_passable;
vec_set (temporary_distance.x, camera.x);
temporary_distance.z -= 50; // sets a position closer to the feet of the player; 50 = experimental value
distance_traced = trace (player.x, temporary_distance.x); // trace between the player and temporary_distance
if (distance_traced == 0) // no obstacles on the way?
{
my.alpha = min (100, my.alpha + 3 * time); // then increase player's alpha up to 100
if (camera_distance < my.skill40) // if the camera got closer to the player
{
camera_distance += 1; // restore the initial camera_distance slowly
}
}
else // obstacles encountered?
{
distance_traced -= 2; // then bring the camera 2 quants closer to the player!
my.alpha = (distance_traced / (my.skill40 + 1)) * 100; // decrease player's alpha; don't allow a division by zero
camera.x = player.x - distance_traced * cos(camera.pan); // place the camera behind the player
camera.y = player.y - distance_traced * sin(camera.pan); // at the new distance given by distance_traced
}
}

function first_person_camera() // press "F1" to run this function
{
camera_distance = 0; // place the camera at player's position
camera_height = 20; // play with this value
player.invisible = on; // make the player model invisible
camera_mode = 1; // set the camera_mode variable to 1st person
}

function third_person_camera() // press "F3" to run this function
{
camera_distance = player.skill40; // restore the distance from the player to the camera
camera_height = player.skill41; // as well as its height
player.invisible = off; // and show the player
camera_mode = 3; // set the camera_mode variable to 3rd person
}

on_f1 = first_person_camera;
on_f3 = third_person_camera;


موفق باشی : ستاره Cool
ارسال  بازگشت به بالا
 

نويسنده
پيغام
همرا
کاربر جدید
کاربر جدید


تاريخ عضويت: 1 شنبه 2 مرداد 1384
تعداد ارسالها: 22


جمعه 12 اسفند 1384 - 15:44
پاسخ بصورت نقل قول
عماد11, میشه یکی بگه چطوری می تونیم این ماشین داغون رو حرکت داد Exclamation Crying or Very sad

_________________
HemrA
داشته هايت را در اختيار ديگران قرار ده تا به نداشته هايت برسي
ارسال  بازگشت به بالا
ديدن مشخصات كاربر ارسال پيغام خصوصي ارسال ايميل نام كاربري در پيغامگير Yahoo
 

نويسنده
پيغام
عماد11
بازی ساز
بازی ساز


تاريخ عضويت: جمعه 7 اسفند 1383
تعداد ارسالها: 229
محل سكونت: تهران


جمعه 12 اسفند 1384 - 19:28
پاسخ بصورت نقل قول
دست شما درد نكنه اگر ممكنه يه كم در مورد كد توضيح دهيد .
Evil or Very Mad عماد

_________________
ارسال  بازگشت به بالا
ديدن مشخصات كاربر ارسال پيغام خصوصي نام كاربري در پيغامگير Yahoo
 

نويسنده
پيغام
مهمان







جمعه 12 اسفند 1384 - 20:27
پاسخ بصورت نقل قول
نقل قول:

اگر ممكنه يه كم در مورد كد توضيح دهيد .


کد بالا در واقع یک برنامه کامل است که شامل تابع Main و اکشن و توابع مورد نیاز است . در این برنامه ، یک محیط سه بعدی ایجاد میشود و کاراکتر انیمیشنی (همان سرباز معروف فایلهای Template) را میتوانید توسط کلید های مکان نما حرکت دهید . زمانی که کارکتر حرکت میکند ، در برخورد با اطراف ، متوقف میشود و این همان چیزی است که شما دنبال آن هستید . پس به قسمت کد های اکشن Player1 توجه کنید و تمام تنظیمات اولیه اتومبیل خود را مطابق با آن تنظیم کنید :

نقل قول:

action player1
{
player = my; // I'm the player
my.x = -2700; // set the proper position and orientation for the player
my.y = -2500; // this is useful if you have a huge level and the player is too small to be noticeable on the map in Wed
my.z = -2000;
my.pan = 160;
my.transparent = on; // the player is transparent
my.alpha = 100; // but opaque if the camera doesn't run into obstacles
my.skill40 = camera_distance; // we store the distance to the camera
my.skill41 = camera_height; // and its height
camera_mode = 3; // the game starts with the camera in 3rd person mode
while (1)
{
player.pan -= 10 * mouse_force.x * time - 1.5 * (key_a - key_d); // player's pan is controlled by the mouse and the "A" and "D" keys
camera.x = player.x - camera_distance * cos(player.pan); // keep the camera behind the player
camera.y = player.y - camera_distance * sin(player.pan); // at the distance given by camera_distance
camera.z = player.z + camera_height + 0.8 * sin(my.skill46 * 3.6); // and above the player
camera.pan = player.pan; // the camera has the same pan angle with the player
camera.tilt += 7 * mouse_force.y * time; // and can tilt freely
camera_distance = min (max (camera_distance, 5), 500); // camera_distance can have values between 5 and 500
if (key_w + key_s > 0) // if the player is walking
{
ent_cycle("walk", my.skill46); // play its "walk" frames animation
my.skill46 += 10 * (1 + key_shift * 0.5) * time; // the animation speed increases when the player presses the "shift" key
my.skill46 %= 100; // loop the animation
}
else // if the player is standing
{
my.skill47 = 0; // reset the skill that stores the distance needed for the step sound (not really needed)
ent_cycle("stand", my.skill48); // play the "stand" frames animation
my.skill48 += 2 * time; // "stand" animation speed
my.skill48 %= 100; // loop animation
}
if (camera_mode == 3) // if we are in 3rd person mode
{
avoid_obstacles(); // run the function that avoids camera collisions with the relief
}
vec_set (temp, my.x); // trace 10,000 quants below the player
temp.z -= 10000;
trace_mode = ignore_me + ignore_passable + use_box;
temp.z = -trace (my.x, temp); // and adjust its height accordingly, placing its feet on the ground
// allow the player to move using the "W" and "S" keys; the speed increases to 200% if the player presses the "shift" key
temp.x = 10 * (key_w - key_s) * (1 + 1 * key_shift) * time;
temp.y = 0;
my.skill47 += ent_move (temp, nullvector);
if (my.skill47 > 50) // play with 50 (here we've got a step sound every 50 quants)
{
snd_play(step_wav, 30, 0);
my.skill47 = 0;
}
wait (1);
}
}


البته با کمی دستکاری میتونید جای دوربین را دقیقا در جایی که میخواهید قرار دهید .

*** نکته مهم :

در برخی موارد ، میتوان با استفاده از تابع vec_dist ، بر خورد یک شئی را با شئی دیگر از طریق تعیین فاصله آنها شناسایی کنید . اگر فرض کنیم که Player بازیگر است و Enemy دشمن ، استفاده از تابع زیر میتواند بر خورد این دو شئی را مشخص کند:

(if(vec_dist(player.x,enemy.x)<50
}
...

عدد 50 ، تعداد فاصله نقاط Player با Enemy است که معمولا از مرکز اشیاء محاسبه میشود . بنابراین ، عدد 50 ارتباط مستقیمی با حجم اشیاء دارد .البته این روش شناسایی دشمنان ، آسانسور ها و درب های خودکار و امثال اینها کاربرد دارد .

به هر صورت ، پیشنهاد میکنم در مرحله نخست از همان قطعه کدی که در بالا آوردم استفاده کنید و اکشن Player1 را به اتومبیل خود اختصاص دهید تا با دیوار ها و سایر اشیاء برخورد کند و از آنها عبور نکند .
اگر باز هم مشکلی داشتی ، حتما مطرح کن

قربانت : ستاره Evil or Very Mad Evil or Very Mad Evil or Very Mad
ارسال  بازگشت به بالا
 

نويسنده
پيغام
mory
مدیر انجمن
مدیر انجمن


تاريخ عضويت: 3 شنبه 3 خرداد 1384
تعداد ارسالها: 1187


شنبه 13 اسفند 1384 - 02:00
پاسخ بصورت نقل قول
نقل قول:

player = my; // I'm the player


بايد اعتراف كنم شما در گذاشتن كامنت براي دستورات يك استاد به تمام معني هستيد . يك سري اسكريپت كه كامنت داشته باشه از هر كتابي سريعتر راهنمايي ميكنه . حيف كه من گيم استوديو كار نمي كنم .

_________________
و مهم نيست كي پنيرتو دزديده قورباغتو قورت بده .

ارسال  بازگشت به بالا
ديدن مشخصات كاربر ارسال پيغام خصوصي ارسال ايميل نام كاربري در پيغامگير Yahoo
 

نويسنده
پيغام
عماد11
بازی ساز
بازی ساز


تاريخ عضويت: جمعه 7 اسفند 1383
تعداد ارسالها: 229
محل سكونت: تهران


شنبه 13 اسفند 1384 - 06:43
پاسخ بصورت نقل قول
من action را به ماشين خود نسبت دادم فقط مي خوام چند خط اضافه كنم كه از ديوار رد نشه .

_________________
ارسال  بازگشت به بالا
ديدن مشخصات كاربر ارسال پيغام خصوصي نام كاربري در پيغامگير Yahoo
 

نويسنده
پيغام
Ali
مدیر کل
مدیر کل


تاريخ عضويت: شنبه 20 تير 1383
تعداد ارسالها: 2983
محل سكونت: On the edge


شنبه 13 اسفند 1384 - 22:54
پاسخ بصورت نقل قول
دوستان فقط محض اطلاع عرض کنم که اگه کدهاتون رو توی تگ code قرار بدین ، دیگه کدهای شما راست چین نمیشه و خیلی راحت تر خونده میشه...




علی

_________________
پی سی گیمرز - آرشيو بزرگ بازی های کامپیوتری
ارسال  بازگشت به بالا
ديدن مشخصات كاربر ارسال پيغام خصوصي ارسال ايميل ديدن وب سايت كاربر نام كاربري در پيغامگير Yahoo
 

نمايش نامه هاي ارسال شده قبلي:   
ارسال يك موضوع جديد   پاسخ به يك موضوع    صفحه 1 از 2 تمام ساعات و تاريخها بر حسب 3.5+ ساعت گرينويچ مي باشد
برو به صفحه 1, 2  بعدي


 
پرش به:  


شما نمي توانيد در اين انجمن نامه ارسال كنيد.
شما نمي توانيد به موضوعات اين انجمن پاسخ دهيد
شما نمي توانيد نامه هاي ارسالي خود را در اين انجمن ويرايش كنيد
شما نمي توانيد نامه هاي ارسالي خود را در اين انجمن حذف كنيد
شما نمي توانيد در نظر سنجي هاي اين انجمن شركت كنيد


unity3d

بازگردانی به فارسی : علی کسایی @ توسعه مجازی کادوس 2004-2011
Powered by phpBB © 2001, 2011 phpBB Group
| Home | عضويت | ليست اعضا | گروه هاي كاربران | جستجو | راهنماي اين انجمن | Log In |